#20653: Security: replace SHA1 with SHA256 for hash generation
agents
size: XS
Cluster:
OpenClaw Plugin Enhancements
## Summary
- Replace SHA1 with SHA256 in `gateway-lock.ts` (lock file name derivation) and `tool-call-id.ts` (tool call ID generation)
- SHA1 is cryptographically broken; SHA256 is the modern standard
- Update corresponding test to match
## Test plan
- [ ] Run `vitest src/infra/gateway-lock.test.ts` to verify lock tests pass
- [ ] Run `vitest src/agents/tool-call-id` to verify tool call ID tests pass
- [ ] Verify existing gateway lock files are cleaned up on upgrade (lock files are transient)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR successfully migrates from SHA1 to SHA256 for hash generation in two non-cryptographic contexts: gateway lock file naming (`gateway-lock.ts`) and tool call ID generation (`tool-call-id.ts`). The changes are minimal and focused - only the hash algorithm parameter is updated from `"sha1"` to `"sha256"`.
- Gateway lock files use an 8-character hash suffix to distinguish locks for different config paths. The hash change will cause old lock files to be orphaned, but since lock files are transient (process-lifetime only), this is harmless.
- Tool call IDs use hashing for collision avoidance and ID generation. These are generated fresh each session and not persisted, so the algorithm change has no backward compatibility impact.
- The test file was correctly updated to match the implementation change.
- Other SHA1 usages in the codebase (`extensions/voice-call/src/webhook-security.ts` for Twilio HMAC, `scripts/debug-claude-usage.ts` for Chrome keychain) are external API requirements and correctly remain unchanged.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk
- The changes are minimal, well-scoped, and correctly implemented. Both use cases (lock file naming and tool call ID generation) are non-cryptographic hashing contexts where the specific hash values don't matter - only uniqueness and determinism. The test file was properly updated, and the migration path is clean since both lock files and tool call IDs are transient. No breaking changes or compatibility issues.
- No files require special attention
<sub>Last reviewed commit: 7327e96</sub>
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#18904: fix(sandbox): restore SHA-1 in slugifySessionKey to preserve worksp...
by steflsd · 2026-02-17
76.2%
#23574: security: P0 critical remediation — plugin sandbox, password hashin...
by lumeleopard001 · 2026-02-22
75.6%
#23671: fix(security): use crypto.randomInt for session slug generation
by kevinWangSheng · 2026-02-22
74.0%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
73.6%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
73.0%
#21964: Security: harden gateway and plugin trust boundaries
by Elormyevu · 2026-02-20
73.0%
#16016: fix: update systemd unit version on gateway restart
by jbold · 2026-02-14
73.0%
#9156: fix(status): refresh version/commit on gateway restart
by gavinbmoore · 2026-02-04
72.9%
#15757: feat(security): add hardening gap audit checks
by saurabhsh5 · 2026-02-13
72.2%
#8779: fix(security): use constant-time comparison for token validation
by hleliofficiel · 2026-02-04
72.1%