fix: resolve 4 critical/high bugs found in security review#168
fix: resolve 4 critical/high bugs found in security review#168HEYALT wants to merge 1 commit intoBigBodyCobain:mainfrom
Conversation
- Fix BigBodyCobain#164: Remove dead code and duplicate function definitions in decrypt_wormhole_dm_envelope. The MLS guard logic, format negotiation, and transport tier checks now execute instead of being bypassed by an immediate return statement. - Fix BigBodyCobain#165: Stop leaking the raw OPENCLAW_HMAC_SECRET in the API response from api_reset_all_agent_credentials. Return a boolean confirmation flag instead. - Fix BigBodyCobain#166: Cache the request body on request._body after HMAC verification in _verify_openclaw_hmac() so downstream route handlers on /api/ai/* can still read the body. - Fix BigBodyCobain#167: Wire the CSP nonce into script-src in production mode, replacing unsafe-inline with nonce-based restrictions. Dev mode retains unsafe-inline for Next.js HMR compatibility.
|
Thanks for putting this together. I reviewed the patch and agree that several of the issues are legitimate, but I do not want to merge this PR as-is because two parts have regression risk. The The The two risky parts are:
The duplicate/dead-code issue is real, but the PR changes behavior by replacing the current delegation path with an older inline decrypt implementation. The current delegated A safer fix would remove the duplicate/dead definitions while keeping the router delegated to the current
The CSP nonce issue is valid, but switching production I am open to a revised PR that splits this into safer commits:
Thanks again. The review was useful; I just want to avoid shipping a security cleanup that accidentally breaks Wormhole/Infonet or first paint. |
Summary
Fixes 4 bugs found during security code review.
Changes
Fix #164 — Dead code in
decrypt_wormhole_dm_envelope(backend/routers/wormhole.py)decrypt_wormhole_dm_envelopedefinition (was defined twice)returnthat made ~80 lines of MLS guard logic, format negotiation, and transport tier checks unreachableimport main as _mFix #165 — HMAC secret leaked in API response (
backend/routers/admin.py)api_reset_all_agent_credentialsno longer returns the rawOPENCLAW_HMAC_SECREThmac_regenerated: trueflagFix #166 — Request body consumed by HMAC middleware (
backend/auth.py)_verify_openclaw_hmac()now cachesbody_bytesonrequest._bodyafter reading/api/ai/*can now access the body after HMAC verificationFix #167 — CSP nonce not wired into
script-src(frontend/src/middleware.ts)'nonce-${nonce}'instead of'unsafe-inline''unsafe-inline' 'unsafe-eval'for Next.js HMR_nonce→nonceparameterCloses #164, Closes #165, Closes #166, Closes #167