fix: avoid shell interpolation in postinstall codesign - #87
Conversation
…ss security vulnerability Automated security fix generated by OrbisAI Security
|
Thanks for this. The Please drop the The direct argument array already handles the quoting concern without modifying filenames. With the traversal restored, this should be a small, straightforward fix to land. Please also check filenames containing spaces, quotes and backslashes with a stubbed signer so the regression is covered without invoking the postinstall rebuild. |
Drop the safeName sanitization added in the previous commit — backslash is a valid filename character on Unix, so stripping it corrupted paths (e.g. native\addon.node became nativeaddon.node) and skipped the contents of any directory whose name contained a backslash. execFileSync already passes the filename as a single argv element with no shell involved, so no sanitization is needed. Also guard the top-level script body with require.main so tests can require findFiles/codesignFile without running the real rebuild/codesign flow, and add regression coverage for filenames with spaces, quotes, and backslashes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for catching this and reproducing the backslash case. You're right — the filename sanitization is unnecessary once the argument is passed directly to I've removed the I've also added regression coverage ( |
|
Thanks @anupamme for the fix and for following up on the filename handling and regression tests! I pushed a small test portability follow-up: the Unix-only filesystem cases now skip on Windows, while the stubbed signer tests use path strings without creating files and still run on every platform. I also added these tests to the build workflow so they run on all four CI targets. All 199 tests pass locally with current main, and the postinstall tests have passed on Windows, macOS, and both Linux targets. The remaining builds are finishing; once they're green, I'll merge this. Thanks again for the contribution! |
Summary
Replace the shell-based codesign invocation in
scripts/postinstall.jswithexecFileSync()so filenames are passed as process arguments rather than interpolated into a shell command.Changes
execSync()withexecFileSync()for the codesign invocation.findFiles()traversal and filenames unchanged.Security
This removes shell interpretation of the discovered filename while preserving existing postinstall behavior.