fix(security): nightwatch.conf.js — env-var creds + own-keys merge (SDK-6070/6072)#84
Open
AakashHotchandani wants to merge 1 commit into
Open
fix(security): nightwatch.conf.js — env-var creds + own-keys merge (SDK-6070/6072)#84AakashHotchandani wants to merge 1 commit into
AakashHotchandani wants to merge 1 commit into
Conversation
…DK-6070, SDK-6072)
Two source-level fixes in the sample config:
- SDK-6070 (CWE-321): credentials were written as single-quoted JS string
literals `'${BROWSERSTACK_USERNAME}'` / `'${BROWSERSTACK_ACCESS_KEY}'`.
Single quotes do not interpolate, so the literal `${...}` string was always
truthy and used verbatim — the env vars were never actually read and the
`|| 'YOUR_...'` fallback was dead code. Switched to
`process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME'` (and access key).
- SDK-6072 (CWE-915): the `for..in` loop over `additonalEnvironments.test_settings`
walked the prototype chain, a prototype-pollution gadget that could inject
attacker-controlled config keys. Switched to
`for (const key of Object.keys(...))` (own enumerable keys only).
Verified: `node --check` passes; the config `require()`s cleanly; test_settings
resolves the same 8 environment keys; userName/accessKey now fall back to the
placeholders when env vars are unset (and read the real env vars when set).
NOTE: logic-vuln changes — flagged for human review (see PR body).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
🤖 Automated review (pr-review agent)Verdict: ✅ Approve (good to go) — one non-blocking defense-in-depth note. Focus-area findings:
Non-blocking note (defense-in-depth): a residual prototype-pollution surface exists only if an upstream caller pollutes the nested Per-file confidence: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two source-level security fixes in
nightwatch.conf.js. Unlike the dependency/CI PRs in this audit, these change runtime behavior, so they're flagged for human review.process.envinstead of non-interpolating string literalsObject.keys) instead of prototype-walkingfor..inSDK-6070 — credentials as JS literals
The single-quoted
'${BROWSERSTACK_USERNAME}'does not interpolate — it's a literal string, always truthy, so the env var was never read and the|| 'YOUR_...'fallback was dead code. Behavioral change to confirm: the sample now actually readsBROWSERSTACK_USERNAME/BROWSERSTACK_ACCESS_KEYfrom the environment (falling back to the placeholder when unset), which is the intended behavior.SDK-6072 — prototype-chain merge
for..inenumerates inherited (prototype-chain) properties; iftest_settings's prototype is polluted, attacker-controlled keys get merged into the nightwatch config.Object.keys()restricts to own enumerable properties. Functionally identical for plain objects.Verification
node --check nightwatch.conf.jspasses.require('./nightwatch.conf.js')loads cleanly;test_settingsresolves the same 8 environment keys (default, browserstack, browserstack.chrome/firefox/edge, env1/2/3).userName/accessKeyfall back to placeholders when env vars are unset.nightwatch.conf.jsonly, 3 ins / 3 del.Jira: SDK-6070, SDK-6072
🤖 Generated with Claude Code