Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Discussion] Contrast reports path traversal vulnerability #486

Closed
francislz opened this issue Dec 29, 2021 · 4 comments
Closed

[Discussion] Contrast reports path traversal vulnerability #486

francislz opened this issue Dec 29, 2021 · 4 comments

Comments

@francislz
Copy link

Contrast reports that the Accept-Language: en-us is vulnerable to Path Traversal since the value is used to access the en.json in the translations folder. According to contrast I might manipulate the this header in order to access the filesystem. I tested it out by manipulating the header but I seems that is a false positive. Just wanted to make sure by creating this discussion here.

@mashpie
Copy link
Owner

mashpie commented Dec 29, 2021

Thanks for pointing. If you have any further details to share or even a POC, please send them by email before disclosing.
Meanwhile I'll test for traversal vulnerability by myself.

@mashpie
Copy link
Owner

mashpie commented Dec 29, 2021

So far I was not able to escape from the locales directory. Any provided locale (be it from accept-header, cookie, query parameter or code) has to match to one of configured locales, ie.:

const i18n = new I18n({
  locales: ['en', 'de'],
  directory: './translations'
})

The first locale will act as default for any "unknown" or manipulated locale. Thus, providing a locale like '../en' or '../de' or '../../' will result in using 'en' with reading/writing the file ./translations/en.json relative to process.env.PWD

Even without explicit config, i18n uses 'en' as default locale and 'locales' as default directory. Example:

const i18n = new I18n({})

can only use ./locales/en.json for any given locale.

I am about to add another test as prove for those cases. And I think there is still room for improving parameter sanitizing and filesystem operations in general.

@francislz
Copy link
Author

francislz commented Dec 29, 2021

@mashpie the tests on my side followed the same logic as yours and I was not able to escape from the locales directory as well. I think it is safe to assume its a false positive. Thanks for the fast response, btw :D

@mashpie
Copy link
Owner

mashpie commented Dec 29, 2021

@francislz Thanks for your effort, I am glad to hear that. Let's keep this issue open for me to further improve sanitizing.

Repository owner locked and limited conversation to collaborators Jan 23, 2022
@mashpie mashpie converted this issue into discussion #490 Jan 23, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants