Skip to content

Conversation

Gilgahex
Copy link

@Gilgahex Gilgahex commented Aug 2, 2022

I even added a test, wow TDD works!

let url = this.getUrl();

//Strip malicious Unicode SNYK-AUTOLINKER-2438289
url.replace('\u202E', '');
Copy link

@bassammaged bassammaged Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I suggest Strip the most RTLO common format U+202E and %E2%80%AE beside \u202E

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should also be replaced globally with /\u202E/g

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would that be immune to ReDoS?

https://en.wikipedia.org/wiki/ReDoS

Copy link
Owner

@gregjacobs gregjacobs Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, not sure how this would actually fix the issue because the code isn't re-assigning the replacement result back to url. The code would need to be:

url = url.replace(/\u202E/g, '');

Does your new test pass even without this new line of code?

Copy link

@xfournet xfournet Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even after correction of the test (see remark in autolinker-url.spec.ts) the test is failing whatever the changes here:

  • with this line
  • with the update line according greg comment
  • without this line

in my observation the \u202e char is never reaching this method because of parseHtml

Update so we can just merge everything
describe('unicode exploits', () => {
it('should strip out Right-To-Left Override Unicode characters for security', () => {
var result = autolinker.link('https://legit.ok/files\u202E4pm.asia');
expect(result).toBe('<a href="https://legit.ok/files4pm.asia"></a>');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the expected result should be '<a href="https://legit.ok/files4pm.asia">legit.ok/files4pm.asia</a>'

@gregjacobs
Copy link
Owner

Hey @Gilgahex, went with another PR for the fix (#386). Thanks for contributing though!

@gregjacobs gregjacobs closed this Sep 7, 2022
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.

5 participants