-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
src: support for reading NODE_EXTRA_CA_CERTS from env file #51497
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
It doesn't seem right to override this with the dot env files without checking privileges which was what SafeGetEnv was for. Maybe @bnoordhuis knows better whether this violates what it tried to guard against. |
src/node_dotenv.cc
Outdated
@@ -108,10 +108,14 @@ bool Dotenv::ParsePath(const std::string_view path) { | |||
} | |||
|
|||
void Dotenv::AssignNodeOptionsIfAvailable(std::string* node_options) { | |||
auto match = store_.find("NODE_OPTIONS"); | |||
AssignValueIfAvailable("NODE_OPTIONS", node_options); |
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.
We don't need this function anymore. Ref: AssignNodeOptionsIfAvailable
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.
got it, fixed
src/node_dotenv.cc
Outdated
AssignValueIfAvailable("NODE_OPTIONS", node_options); | ||
} | ||
|
||
void Dotenv::AssignValueIfAvailable(const char* key, std::string* value) { |
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.
void Dotenv::AssignValueIfAvailable(const char* key, std::string* value) { | |
void Dotenv::AssignValueIfAvailable(const std::string& key, std::string* value) { |
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.
fixed
Thanks @joyeecheung, I'm not sure whether this change is reliable. @bnoordhuis If you are free, please help to review it. Update: I check the comment on |
5f4f97a
to
b012fa7
Compare
any update? |
I think we need someone like @bnoorhuis or someone from @nodejs/security to review it and confirm that this is not introducing a attack vector |
Just briefly looked at it so I hope I don't miss anything important. Here's my observation:
|
I think the original intent of SafeGetEnv is to guard against e.g. improper permission escalation when the binary gets the setuid bit set. Not sure what the threat model is. It might also make sense to completely ignore the .env file when the binary gets modified like that. |
so need to do the same check like |
That would be what I'd do - just ignoring the .env too when the permission check fails - but I don't think I am familiar enough with the original threat model to make a call. |
Fixes: #51426