T07 · Tool Hijacking and Spoofing
- Location
scripts/office/soffice.py:41- Finding
Predictable Temporary LD_PRELOAD Library Allows Local Tool Hijacking
- Content
View full analysis
bool: try: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.close() return False except OSError: return True def _ensure_shim() -> Path: if _SHIM_SO.exists(): return _SHIM_SO src = Path(tempfile.gettempdir()) / "lo_socket_shim.c" src.write_text(_SHIM_SOURCE) subprocess.run( ["gcc", "-shared", "-fPIC", "-o", str(_SHIM_SO), str(src), "-ldl"], check=True, capture_output=True, ) src.unlink() return _SHIM_SO ``` The returned path is subsequently assigned to `LD_PRELOAD`: ```python if _needs_shim(): shim = _ensure_shim() env["LD_PRELOAD"] = str(shim) ``` ### Technical Analysis The shared object is stored under a fixed, globally predictable path in the system temporary directory. `_ensure_shim()` considers the file trustworthy solely because it exists. It does not verify its owner, permissions, file type, cryptographic digest, source, or whether it is a symbolic link. On a multi-user system, an attacker can create `/tmp/lo_socket_shim.so` before the skill runs. When AF_UNIX socket creation fails and the compatibility path is activated, the existing attacker-controlled library is placed in `LD_PRELOAD`. The dynamic linker then loads it into the `soffice` process before normal application initialization. The source file `/tmp/lo_socket_shim.c` is also predictable. Concurrent invocations can overwrite, compile, or delete each other's source and output files, creating race conditions and further opportunities for tampering. ### Attack Path 1. The attacker has local access to the same host or can run another workload sharing the global te ...[truncated 1393 chars]- Remediation
View remediation
