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

Fixed $sanitizing so that XSS attack are not possible #72

Merged
merged 1 commit into from Jan 17, 2014
Merged

Fixed $sanitizing so that XSS attack are not possible #72

merged 1 commit into from Jan 17, 2014

Conversation

JonathanGawrych
Copy link
Contributor

Fixes the problems discussed in issue #62

This pull request has 3 parts:
First, the value was never assigned to the returned sanitized value, so that part is fixed
Second, there was a small hole in $oldViewValue, iff bad code was loaded, and contained invalid HTML
Third, $formatters as well as $parsers need to be sanitized

Thanks!

@JonathanGawrych
Copy link
Contributor Author

The small hole I talked about in the second part refers to this line

if(ngModel.$oldViewValue === undefined) ngModel.$oldViewValue = value;

An attacker may bypass $sanitize by summiting invalid html with an attack on the first run when $oldViewValue is undefined.
Here's how:

submit value with XSSAttackWithInvalidHTML
ngModel.$oldViewValue is undefined thus:
    ngModel.$oldViewValue is set to XSSAttackWithInvalidHTML
try to $sanitize(XSSAttackWithInvalidHTML):
    Error is thrown
    Goto catch block
catch error
    assumes $oldViewValue is safe
    returns $oldViewValue with XSSAttackWithInvalidHTML
Browser will reject invalid HTML, but will still accept the well-formed parts (XSSAttack)
    XSSAttack is executed

…th $oldViewValue, and attacks that were uploaded to the server and served to others
@JonathanGawrych
Copy link
Contributor Author

Updated my pull request to include the minified version
minified using uglifyjs version: 2.4.9

SimeonC pushed a commit that referenced this pull request Jan 17, 2014
Fixed $sanitizing so that XSS attack are not possible
@SimeonC SimeonC merged commit eea6ec6 into textAngular:master Jan 17, 2014
@SimeonC
Copy link
Collaborator

SimeonC commented Jan 17, 2014

Awesome thanks! I'll make sure to update the changes I'd done in 1.2.0 branch to include your work when I get the chance.

I'm intending on using an optional custom branch of angular-sanitize to allow certain styles/tags through, namely color in the style attribute at present as that's the only attribute that's impractical to use through classes. (That I've thought of so far).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants