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

Defensive check for process.config.variables (v4-staging) #6114

Closed
wants to merge 1 commit into from
Closed

Defensive check for process.config.variables (v4-staging) #6114

wants to merge 1 commit into from

Conversation

sneak
Copy link

@sneak sneak commented Apr 8, 2016

Updated defensive fix (v2 PR of #6110)

Discussion here:

#3755 (comment)

@sneak sneak changed the title Defensive check for process.config.variables Defensive check for process.config.variables (v4-staging) Apr 8, 2016
@mscdex mscdex added build Issues and PRs related to build files or the CI. process Issues and PRs related to the process subsystem. v4.x labels Apr 8, 2016
@jasnell
Copy link
Member

jasnell commented Apr 8, 2016

@@ -19,7 +19,7 @@ const defaultSessionIdContext = getDefaultSessionIdContext();
function getDefaultSessionIdContext() {
var defaultText = process.argv.join(' ');
/* SSL_MAX_SID_CTX_LENGTH is 128 bits */
if (process.config.variables.openssl_fips) {
if (process.config && process.config.variables && process.config.variables.openssl_fips) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this needs to be line-wrapped but that can be done when the PR is landed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally wrap long lines myself but I decided to go with your suggestion from the previous PR:

#6110 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;-) yeah, I was being lazy. Sorry about that. As I said, the linting nit can be addressed when the PR is landed.

@jasnell
Copy link
Member

jasnell commented Apr 8, 2016

LGTM if CI is green.
One minor linting nit.

@Fishrock123
Copy link
Contributor

Why is this directly landing against release branches and not landing is master?

@sneak
Copy link
Author

sneak commented Apr 8, 2016

I haven't tested against master. The problem occurs in latest 4.x and 5.x release. The lines for the fix aren't in the same file in master and I'm not sure why - I don't know your workflow.

@jasnell
Copy link
Member

jasnell commented Apr 8, 2016

The offending line of code does not exist in master. This is going to need a regression test that repro's the issue before it lands, which I'll be working on. In theory this shouldn't be happening so I need to investigate that a bit more.

@MylesBorins
Copy link
Contributor

@jasnell do you want to land this in the next v4.x?

@jasnell
Copy link
Member

jasnell commented Apr 9, 2016

Yes, we should. A quick investigation shows that there are existing modules that mutate process.config (which is problematic). This will need a quick regression test and a CI run plus a linting fix before it can land.

@MylesBorins
Copy link
Contributor

@sneak a new v4.x is going out tomorrow. If you can get through @jasnell 's check list we can likely include it

@stefanmb
Copy link
Contributor

Hi folks, I apologize about being late to this issue, I was away last week.

I agree that breaking existing apps is unacceptable, but I am not sure what we are proposing here is sufficient. While this PR fixes @sneak's problem, what about the reverse issue? If someone is using Node.js 4.x in FIPS mode and loads some code that replaces the process object as per #6115 (comment), then their app will also break. As I see it there are several possible approaches:

  1. Do nothing, process object is assumed to exist and not be clobbered.
  2. Use defensive programming, like this PR, which only fixes the problem for non-FIPS users.
  3. Process object should be frozen as per @Fishrock123's suggestion here Defensive fix for process.config.variables regression (v5) #6115 (comment).
  4. Introduce a new configuration object, that is frozen, and use that instead of process. However, this approach seems unlikely since it is only needed for 4.x and 5.x because the master does not fallback to md5 at all.

Just to make my position clear, I'm not opposed to landing this PR, as the original problem is real and it needs fixing, but we don't yet have a complete solution.

@jasnell
Copy link
Member

jasnell commented Apr 20, 2016

Quick update on this: I'm working on getting #6266 landed in master. Once that's landed, I plan to backport it to v5 and v4 and refactor the parts inside lib/* that depend directly on process.config to avoid this issue entirely.

@MylesBorins MylesBorins force-pushed the v4.x-staging branch 3 times, most recently from ed3d372 to f14d9cf Compare June 28, 2016 22:49
jasnell added a commit to jasnell/node that referenced this pull request Jul 5, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see nodejs#6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: nodejs#6114
@jasnell
Copy link
Member

jasnell commented Jul 6, 2016

Closing this in favor of #7551

@jasnell jasnell closed this Jul 6, 2016
MylesBorins pushed a commit that referenced this pull request Jul 11, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see #6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: #6114
MylesBorins pushed a commit that referenced this pull request Jul 11, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see #6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: #6114
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see #6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: #6114
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see #6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: #6114

PR-URL: #7551
Reviewed-By: Myles Borins <myles.borins@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
When the fips mode check was added sometime in v4 it caused a
regression in some edge cases (see #6114)
because `process.config` can be overwritten by userland modules.
This switches to using the backported process.binding('config') to
fix the regression.

Fixes: #6114

PR-URL: #7551
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants