fix: remove shell injection from socket existence check - #239
Merged
GitGab19 merged 1 commit intoAug 10, 2026
Merged
Conversation
GitGab19
reviewed
Aug 7, 2026
Comment on lines
+33
to
+47
| test('bitcoinSocketExistsScript exits 0 when the socket exists and non-zero otherwise', () => { | ||
| const tmp = mkdtempSync(path.join(tmpdir(), 'sock-exists-')); | ||
| try { | ||
| const socketPath = path.join(tmp, 'node.sock'); | ||
| execFileSync(process.execPath, ['-e', bitcoinSocketExistsScript, socketPath], { | ||
| stdio: 'ignore', | ||
| }); | ||
| assert.fail('expected non-zero exit for missing socket'); | ||
| } catch (err) { | ||
| assert.ok( | ||
| err && typeof err === 'object' && 'status' in err && err.status !== 0, | ||
| 'missing socket should exit non-zero', | ||
| ); | ||
| } | ||
| }); |
Member
There was a problem hiding this comment.
Clanker suggestion:
This test name says it covers both success and failure, but it only asserts the missing-path failure case. Could we also create the path and assert the script exits successfully? That would catch regressions where the probe always returns non-zero.
Suggested change
| test('bitcoinSocketExistsScript exits 0 when the socket exists and non-zero otherwise', () => { | |
| const tmp = mkdtempSync(path.join(tmpdir(), 'sock-exists-')); | |
| try { | |
| const socketPath = path.join(tmp, 'node.sock'); | |
| execFileSync(process.execPath, ['-e', bitcoinSocketExistsScript, socketPath], { | |
| stdio: 'ignore', | |
| }); | |
| assert.fail('expected non-zero exit for missing socket'); | |
| } catch (err) { | |
| assert.ok( | |
| err && typeof err === 'object' && 'status' in err && err.status !== 0, | |
| 'missing socket should exit non-zero', | |
| ); | |
| } | |
| }); | |
| test('bitcoinSocketExistsScript exits 0 when the socket path exists and non-zero otherwise', () => { | |
| const tmp = mkdtempSync(path.join(tmpdir(), 'sock-exists-')); | |
| try { | |
| const socketPath = path.join(tmp, 'node.sock'); | |
| assert.throws( | |
| () => execFileSync(process.execPath, ['-e', bitcoinSocketExistsScript, socketPath], { | |
| stdio: 'ignore', | |
| }), | |
| /Command failed/, | |
| 'missing socket path should exit non-zero', | |
| ); | |
| writeFileSync(socketPath, ''); | |
| execFileSync(process.execPath, ['-e', bitcoinSocketExistsScript, socketPath], { | |
| stdio: 'ignore', | |
| }); | |
| } finally { | |
| rmSync(tmp, { recursive: true, force: true }); | |
| } | |
| }); |
Collaborator
Author
There was a problem hiding this comment.
amended the suggestion
Member
|
Tested on Linux.
So the |
lucasbalieiro
force-pushed
the
fix-cwe78-on-bitcoin-sock-probe
branch
from
August 7, 2026 15:29
8e031ab to
a8de31c
Compare
GitGab19
approved these changes
Aug 10, 2026
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.
closes https://github.com/project-loupe/audit-sv2-ui/issues/6
needs testing on linux to see if the node.sock probe still working from docker and dev envs