T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/benchmark-cache.py:22
- Finding
- Privileged System-Wide Cache Eviction in Benchmark Script## 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**: Medium ### Vulnerable 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 False ``` ### Technical Analysis The cache benchmark directly invokes `sudo` and uses a privileged shell to write `3` to `/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.md` without 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 1. A user follows the documented instruction to run `python3 scripts/benchmark-cache.py`. 2. The script immediately calls `drop_cache()` and launches `sudo sync`. 3. The s ...[truncated 1148 chars]
- Remediation
- ## Remediation Suggestions 1. Remove automatic OS cache eviction from the standard benchmark and compare first-run and subsequent-run performance without elevated privileges. 2. Do not invoke `sudo` from application or benchmark code. If genuine cold-cache testing is required, document it as a separate manual administrative procedure. 3. Run cold-cache benchmarks inside a disposable virtual machine or otherwise isolated dedicated test host where global cache eviction cannot affect unrelated workloads. 4. 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. 5. Detect shared or containerized environments and refuse the privileged operation where isolation cannot be guaranteed. 6. Update `SKILL.md` to disclose the privilege request, affected kernel interface, host-wide scope, and safer non-privileged benchmark mode. 7. Prefer process-scoped measurement controls, repeated trials, randomized query ordering, and statistical reporting rather than manipulating a global kernel cache.
