Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input validation to report generator controller endpoints. #1219

Merged
merged 2 commits into from
Feb 29, 2020

Conversation

jpwhite4
Copy link
Member

Description

This pull request adds input validation filters to the user-supplied
untrusted data provided to the report generator controller endpoints.

The modifications do not change any of the data serialization or api of
the endpoints.

The user-supplied report text (title, header, footer etc.) is modified
to filter out data that does not have a valid character encoding. This
mitigates a bug in the report generator if you tried to create a report
with a filename containing an invalid character such as 😊 then the UI would
show an error message:

There was a problem creating / updating this report.
(SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like')

the new behaviour is that the report will save ok but any invalid
characters will be converted to '?'. A complete fix for this bug is
beyond the scope of this pull request.

Motivation and Context

Potential security vulnerability using untrusted user data.

Tests performed

There are several complex regular expressions used to validate the data
this is necessary due to the non-standard serialization used in the
report generator. Unit tests have been added to confirm that the more
complex regular expressions used do pass through permissible data.

@jpwhite4 jpwhite4 added bug Bugfixes Category:Report Generator Report Generator labels Jan 23, 2020
@jpwhite4 jpwhite4 added this to the 9.0.0 milestone Jan 23, 2020
jpwhite4 and others added 2 commits February 28, 2020 16:16
This pull request adds input validation filters to the user-supplied
untrusted data provided to the report generator controller endpoints.

The modifications do not change any of the data serialization or api of
the endpoints.

The user-supplied report text (title, header, footer etc.) is modified
to filter out data that does not have a valid character encoding. This
mitigates a bug in the report generator if you tried to create a report
with a filename containing an invalid character such as 😊 then the UI would
show an error message:

```
There was a problem creating / updating this report.
(SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like')
```

the new behaviour is that the report will save ok but any invalid
characters will be converted to '?'. A complete fix for this bug is
beyond the scope of this pull request.

There are several complex regular expressions used to validate the data
this is necessary due to the non-standard serialization used in the
report generator.  Unit tests have been added to confirm that the more
complex regular expressions used do pass through permissable data.
Co-Authored-By: Jeffrey T. Palmer <jeffrey.t.palmer@gmail.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 6 Security Hotspots to review)
Code Smell A 5 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jpwhite4 jpwhite4 merged commit 26e179f into ubccr:xdmod9.0 Feb 29, 2020
@jpwhite4 jpwhite4 deleted the input_validation branch February 29, 2020 01:50
jpwhite4 added a commit to jpwhite4/xdmod that referenced this pull request Apr 29, 2020
Fix regression added in ubccr#1219
The report identifiers look different when the report is autogenerated
by the user dashboard infrastructure.

Unit test has been updated to test this condition too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes Category:Report Generator Report Generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants