fix(security): harden against shell injection, command execution, and timing attacks #193
+465
−527
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.
Summary
requestIdbefore shell interpolation in device approval to prevent command injection/debug/cliendpoint — onlyclawdbot,node --version,ls,ps, etc. are permittedtrustedProxiesfrom0.0.0.0/0to localhost only (127.0.0.0/8,::1/128)[SECURITY WARNING]whenDEV_MODEbypasses auth alongside CF Access configsrc/utils/audit.ts) for auth, device approval, gateway restart, storage sync, and debug commandsconsole.loglines that leaked env var presenceAuthorization: Bearerheader for CDP auth (query param still works as fallback); refactor 4 duplicated auth checks into shared helpertimingSafeEqualto not leak secret length via early return on length mismatchTest plan
rm -rf dist && npm run buildpasses with zero TypeScript errorsPOST /api/admin/devices/foo;curl+evil.com/approvereturns 400/debug/cli?cmd=rm+-rf+/returns 403/debug/gateway-api?path=../../etc/passwdreturns 400trustedProxiesAuthorization: Bearerheader and?secret=query param🤖 Generated with Claude Code