fix(security): harden AgentDriveArchiveMemberApi signed-URL verification
AgentDriveArchiveMemberApi signed-URL verification is non-constant-time, accepts future timestamps, and has no replay protection
api/services/agent_drive_service.py verify_archive_member_signature is the sole authorization on the unauthenticated GET /files/agent-drive/archive-member endpoint. Three weaknesses in the verification together let an attacker who intercepts a signed URL (logs, browser history, referer leaks, accidental sharing) read the underlying archive bytes indefinitely and also brute-force the signature itself.
Issues
-
Non-constant-time signature comparison (
agent_drive_service.py:1206). The verification usessign != cls._sign_archive_member_payload(payload), which short-circuits on the first mismatching byte and leaks signature bytes via timing. The signature can be brute-forced one byte at a time from a network-adjacent position. -
No lower-bound timestamp check (
agent_drive_service.py:1209). Only the upper bound is enforced (current_time - int(timestamp) <= FILES_ACCESS_TIMEOUT). A captured URL with a forged far-future timestamp stays valid indefinitely. There is no check that the timestamp is not in the future, even with a small clock-skew allowance. -
No replay protection. The
noncefield is part of the signed payload but is never recorded server-side, so a captured URL is fully replayable for the entire access window.
Attack scenarios
- Intercept any signed archive-member URL — from server access logs, browser history, accidental sharing, or referer leakage — and reuse it indefinitely. Default
FILES_ACCESS_TIMEOUTis 300 seconds; the lack of nonce tracking means a single interception is enough. - Brute-force the signature one byte at a time by measuring response time. The endpoint is unauthenticated, so the attacker can probe from any IP.
Fix
- Replace
sign != ...withhmac.compare_digest(sign, ...). - Reject timestamps that are more than a small clock-skew window in the future, in addition to the existing upper-bound check.
- Record the nonce in Redis with the same TTL as the access window using
SET ... NXfor atomic first-use semantics; repeat attempts find the key already present and are rejected.
Hi @AlexMultiAgent, thanks for opening this issue.
Why this is being closed
The report raises possible signature-verification concerns, but does not identify the tested Dify version or commit, deployment, or a complete proof of concept. The security team needs those details to verify the claimed impact privately. The bug report template asks for version, deployment and reproduction context. This closure does not establish whether the observation is correct.
Next steps
Please share the exact version, deployment and a complete sanitized proof of concept through the private advisory process below. Do not post live signed URLs or other secrets here.
First, if you believe this is a security-related issue, please submit it through a GitHub Advisory and please provide a complete proof of concept (PoC)
https://github.com/langgenius/dify/security/advisories/new
Once the context is available, a maintainer can reassess the report.