T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/benchmark-cache.py:22- Finding
Privileged System-Wide Cache Eviction in Benchmark Script
- Content
View full analysis
Vulnerability Details
File Location:
scripts/benchmark-cache.py, lines 22-39
Vulnerability Type: Unnecessary privilege escalation and modification of a system-wide kernel control
Risk Level: MediumVulnerable Code
python def drop_cache(): """Drop OS page cache (Linux only, requires sudo)""" try: # Drop page cache, dentries, inodes subprocess.run( ["sudo", "sync"], check=True, capture_output=True ) subprocess.run( ["sudo", "sh", "-c", "echo 3 > /proc/sys/vm/drop_caches"], check=True, capture_output=True ) return True except Exception as e: print(f"Warning: Could not drop OS cache ({e})") print("Running benchmark without cache drop...") return FalseTechnical Analysis
The cache benchmark directly invokes
sudoand uses a privileged shell to write3to/proc/sys/vm/drop_caches. This kernel interface evicts the host's page cache, dentries, and inode caches. It is a global system operation rather than an action scoped to the benchmark process or its SQLite database.Normal indexing and search operations do not require elevated privileges. Requesting authorization to modify a system-wide kernel control therefore violates least-privilege principles. The benchmark is also recommended in
SKILL.mdwithout a prominent warning that it may request administrative privileges and affect unrelated workloads.The command is represented as a fixed argument list, so no user-controlled command-injection path was identified. The security issue is the unnecessary privileged operation itself rather than arbitrary shell-command execution.
Attack Path
- A user follows the documented instruction to run
python3 scripts/benchmark-cache.py. - The script immediately calls
drop_cache()and launchessudo sync. - The s ...[truncated 1148 chars]
- A user follows the documented instruction to run
- Remediation
View remediation
Remediation Suggestions
- Remove automatic OS cache eviction from the standard benchmark and compare first-run and subsequent-run performance without elevated privileges.
- Do not invoke
sudofrom application or benchmark code. If genuine cold-cache testing is required, document it as a separate manual administrative procedure. - Run cold-cache benchmarks inside a disposable virtual machine or otherwise isolated dedicated test host where global cache eviction cannot affect unrelated workloads.
- If the feature must remain, require an explicit option such as
--drop-system-cache; keep it disabled by default and display a clear confirmation describing the host-wide impact. - Detect shared or containerized environments and refuse the privileged operation where isolation cannot be guaranteed.
- Update
SKILL.mdto disclose the privilege request, affected kernel interface, host-wide scope, and safer non-privileged benchmark mode. - Prefer process-scoped measurement controls, repeated trials, randomized query ordering, and statistical reporting rather than manipulating a global kernel cache.
