-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: model path-is-inside
+is-path-inside
for js/path-injection
#2723
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
Conversation
var inside = require("path-is-inside")
inside("foo/bar/../../../../../etc/passwd", "foo/bar") === true The |
outcome = true | ||
// Note that `is-path-inside` states: | ||
// > "Note that relative paths are resolved against process.cwd() to make them absolute." | ||
// so it may be possible to undo this sanitization by later prepending some other path to the sanitized path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave this comment here? Doesn't seem like something we need to worry about.
|
||
IsInsideCheckSanitizer() { | ||
exists(string name, DataFlow::CallNode check | | ||
name = "path-is-inside" or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line with @erik-krogh's comment, could you make path-is-inside
only sanitize normalized absolute paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am waiting to see if Erik's PR against path-is-inside
gets accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That PR seems to have entered the void. path-is-inside
is now a weaker sanitizer.
9d4b0df
to
63a0d6b
Compare
63a0d6b
to
0061c0e
Compare
0061c0e
to
5baba62
Compare
I forgot about |
The following pattern sanitizes paths wrt. path injection.
This PR models two confusingly similar packages: 'path-is-inside' and 'is-'path-inside' for that purpose.
Evaluation is pending.