#13144: harden archive extraction, auth tokens, hook transforms, and queue limits
gateway
stale
Cluster:
OpenClaw Plugin Enhancements
1. Tar archive extraction path traversal (src/infra/archive.ts)
- Added a `filter` callback to `tar.x()` that validates each entry path resolves within the destination directory before extraction. The zip extraction path already had this check; tar did not.
2. Hook token timing attack (src/gateway/server-http.ts)
- Replaced plain `!==` string comparison of the webhook hook token with `crypto.timingSafeEqual`, preventing character-by-character brute-force via response-time measurement. The main gateway auth already used timing-safe comparison; the hook endpoint did not.
3. TLS fingerprint pinning clarity (src/gateway/client.ts)
- Documented why `rejectUnauthorized: false` is required when using certificate fingerprint pinning with self-signed certificates generated by the gateway's auto-TLS feature.
4. Hook transform module path traversal (src/gateway/hooks-mapping.ts)
- `resolvePath()` previously accepted absolute paths and `../` sequences, allowing a malicious config to load and execute arbitrary JS files via `import()`. Now validates that the resolved path stays within the transforms base directory.
5. Unbounded command queue DoS (src/process/command-queue.ts)
- Added a per-lane max queue depth (default 1000). Enqueue attempts beyond this limit are rejected immediately with an error, preventing memory exhaustion from unbounded task accumulation.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Changes focus on hardening several security-sensitive areas:
- Adds a path containment check for tar extraction entries (matching existing zip behavior).
- Switches webhook hook token comparison to `timingSafeEqual`.
- Documents the trust model when using TLS fingerprint pinning with self-signed gateway certs.
- Restricts hook transform module resolution to remain within the configured transforms base directory.
- Adds a per-lane maximum queue depth to prevent unbounded command queue growth.
Overall, the PR moves multiple edge cases toward safer defaults, but there are a couple of correctness/portability issues in the new path and queue-limit checks that should be addressed before merging.
<h3>Confidence Score: 3/5</h3>
- This PR is directionally good but has a few correctness/portability issues to address before merging.
- Security hardening changes are generally sound, but the new path containment check relies on string prefix logic that can misbehave on case-insensitive platforms, and the new queue limit semantics may not enforce the intended hard cap. These should be corrected to avoid false rejections or incomplete protection.
- src/gateway/hooks-mapping.ts, src/process/command-queue.ts, src/infra/archive.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21964: Security: harden gateway and plugin trust boundaries
by Elormyevu · 2026-02-20
80.6%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
80.1%
#6405: feat(security): Add HTTP API security hooks for plugin scanning
by masterfung · 2026-02-01
79.8%
#7616: Harden zip extraction against path traversal
by lawyered0 · 2026-02-03
79.3%
#10745: feat: Security improvements and Windows compatibility fixes
by lluviaoscuradeldoce-design · 2026-02-06
78.8%
#8876: Confirmaciones para equipo de IT
by m4xjunior · 2026-02-04
78.6%
#9529: security(archive): validate entries against path traversal (Zip Slip)
by leszekszpunar · 2026-02-05
78.1%
#14222: core: add needsApproval to before_tool_call; move AgentShield to ex...
by Eventedge · 2026-02-11
77.0%
#15571: feat: infrastructure foundation — hooks, model failover, sessions, ...
by tangcruz · 2026-02-13
76.9%
#9914: fix(hooks): resolve bundled hook dist paths and packaging checks
by zimmra · 2026-02-05
76.7%