-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
fix: ensure TraverseParent
bails on resource path exit
#46100
Conversation
a029b69
to
5b2409f
Compare
df72c27
to
c94c6a1
Compare
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.
lgtm pending CI
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
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.
Concept LGTM. 👍
I had some implementation nit suggestions but nothing major
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
c94c6a1
to
827b5d8
Compare
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
827b5d8
to
df1b767
Compare
patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch
Outdated
Show resolved
Hide resolved
9dd38d6
to
6efc060
Compare
6efc060
to
6f28203
Compare
6f28203
to
3a2b0eb
Compare
@MarshallOfSound i think |
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.
Approving as it fixes the underlying issues, one fast-follow request and two non-blocking comments
const bool is_permissions_enabled = env->permission()->enabled(); | ||
|
||
+ // Get the resources path with trailing slash. | ||
+ std::string resources_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.
non-blocking-fast-follow: This is susceptible to userland modification of resourcesPath
, unlike the impl in node/init.ts
which captures the value before userland code runs.
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.
non-blocking: this also has a perf hit during module loading as we're reading this on every module load, we should be able to cache this in a base::NoDestructor<std::string>
or something for future use
+ auto starts_with = [](const std::string& str, const std::string& prefix) -> bool { | ||
+ if (prefix.size() > str.size()) return false; | ||
+ return std::equal( | ||
+ prefix.begin(), prefix.end(), str.begin(), | ||
+ [](char a, char b) { | ||
+ return std::tolower(static_cast<unsigned char>(a)) == | ||
+ std::tolower(static_cast<unsigned char>(b)); | ||
+ }); | ||
+ }; |
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.
non-blocking-question: does this have to be here? or could it be in an anonymous namespace? Wondering if this was just for patch readability
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.
@MarshallOfSound it was for patch readability and keeping changes closer together, yeah
No Release Notes |
I have automatically backported this PR to "36-x-y", please check out #46212 |
I have automatically backported this PR to "35-x-y", please check out #46213 |
Description of Change
Electron's security model requires that we do not traverse outside of the resource path. This PR ensures that the TraverseParent function bails out if the parent path is outside of the resource path.
Checklist
npm test
passesRelease Notes
Notes: none