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

Dependency 'uri-template-lite' does not pass strict Content Security Policy #1007

Closed
MrFix93 opened this issue Aug 7, 2019 · 9 comments
Closed

Comments

@MrFix93
Copy link
Contributor

MrFix93 commented Aug 7, 2019

Our application uses a strict Content Security Policy (script-src 'self'). This policy does not allow any runtime code generation. However, Redoc is not able to render anymore as the dependency, uri-template-lite, defines functions by concatenating string. This practice is vulnerable for XSS attacks as we can hardly distinguish XSS attacks from normal behaviour.

The error you get when the CSP policy is strict:

Something went wrong...
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self'".
Stack trace
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self'".

    at Function (<anonymous>)
    at new e.Template (http://localhost:8080/main.8c597251c61602a065f6.js:159:1365)
    at Pe (http://localhost:8080/main.8c597251c61602a065f6.js:48:215000)
    at http://localhost:8080/main.8c597251c61602a065f6.js:48:215957
    at je (http://localhost:8080/main.8c597251c61602a065f6.js:48:216496)
    at t.render (http://localhost:8080/main.8c597251c61602a065f6.js:48:311495)
    at Oo (http://localhost:8080/main.8c597251c61602a065f6.js:69:63010)
    at To (http://localhost:8080/main.8c597251c61602a065f6.js:69:62805)
    at Ro (http://localhost:8080/main.8c597251c61602a065f6.js:69:66639)
    at $a (http://localhost:8080/main.8c597251c61602a065f6.js:69:90683)

ReDoc Version: 2.0.0-rc.12 
Commit: 36ebbb1

Currently, I'm preparing a PR to fix this issue.

@RomanHotsiy
Copy link
Member

Oh.. A lot of issues emerged after merging PR with uri-template-lite...

Currently, I'm preparing a PR to fix this issue.

Awesome! 👍 How are you going to fix it?

@MrFix93
Copy link
Contributor Author

MrFix93 commented Aug 7, 2019

I swap the uri-template-lite to url-template.

@RomanHotsiy
Copy link
Member

The only thing that I am concerned about is that url-template has been last updated 3 years ago. But considering it doesn't have any dependencies, I don't think it's an issue.

MrFix93 pushed a commit to MrFix93/redoc that referenced this issue Aug 7, 2019
Use a different url template dependency that does not have the XSS
vulnerability as stated in Redocly#1007.

Also corrected a test that was not conform the spec.
@MartinKanters
Copy link

I would love to see this in a new version! We are currently blocked by this pretty heavily. Any idea when a new release candidate can be released?

@RomanHotsiy
Copy link
Member

Going to release a new version on weekends

@MartinKanters
Copy link

Perfect, thanks!

@MrFix93
Copy link
Contributor Author

MrFix93 commented Sep 2, 2019

@RomanHotsiy Any update on releasing the fix? Unfortunately, we are still blocked by this issue.

@MartinKanters
Copy link

@RomanHotsiy Sorry to bother you again, Roman, but can I help somehow to streamline this process of the release? I don't want to be a nuisance, but this PR improves the security a lot of the project :)

@RomanHotsiy
Copy link
Member

Sorry for super long delay. I was traveling. I am about to release a new version.

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 a pull request may close this issue.

3 participants