Detect CVE-2026-113715: virtualenv pyvenv.cfg Line Injection via str.splitlines (CWE-93) in Elastic Security
Detects vulnerable usage and attempted exploitation of CVE-2026-113715, a line-injection flaw (CWE-93) in virtualenv prior to 21.14.9. The stdlib venv creator reads the generated pyvenv.cfg with Python's str.splitlines(), which treats a wider set of Unicode line-boundary characters (for example U+000B, U+000C, U+001C to U+001E, U+0085, U+2028, U+2029) as line separators than the writer that produced the file. A caller who can influence the destination pathname passed to the venv creator can embed such a character and inject configuration keys such as 'home' and 'include-system-site-packages' during readback. Setting include-system-site-packages to true weakens environment isolation. An altered home can change which standard-library files the interpreter loads if the attacker also controls that location. The builtin creator does not use this readback path. This detection surfaces vulnerable virtualenv versions and pyvenv.cfg files that contain anomalous line-boundary characters. The advisory rates the overall severity low.
MITRE ATT&CK
- Tactic
- Initial Access Execution Persistence
Elastic Detection Query
// df00tech DF00-2ec4c2eb68 · https://df00tech.com/detections/CVE-2026-113715 · licence: https://df00tech.com/detections/licence
file where event.type in ("creation", "change") and file.name == "pyvenv.cfg" and
process.name in ("python", "python3", "virtualenv", "python.exe") EQL rule flagging pyvenv.cfg creation/modification by python or virtualenv processes; correlate with content inspection for anomalous line-boundary characters to confirm CVE-2026-113715 exploitation.
Data Sources
Required Tables
False Positives & Tuning
- Normal virtual environment creation by developers
- Patched virtualenv >= 21.14.9 writing cfg files legitimately
- Container image builds that create venvs
Other platforms for CVE-2026-113715
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.
- Test 1 Create pyvenv.cfg with vertical-tab line injection
Expected signal: File creation event for /tmp/atomic_venv/pyvenv.cfg containing a 0x0b byte.
- Test 2 Create pyvenv.cfg with NEL (U+0085) separator
Expected signal: File creation event for pyvenv.cfg containing the UTF-8 encoded NEL sequence 0xC2 0x85.
- Test 3 Install vulnerable virtualenv version
Expected signal: Process creation and pip install events recording virtualenv 20.25.0.
- Test 4 Form-feed injection on macOS
Expected signal: File creation event for pyvenv.cfg containing a 0x0c byte.
Response Playbook
Triage
- Confirm the installed virtualenv version on the affected host: run `python -m virtualenv --version` or `pip show virtualenv`; versions >= 20.0.0 and < 21.14.9 are vulnerable.
- Retrieve the flagged pyvenv.cfg file and inspect it for embedded line-boundary characters using `python3 -c "print(repr(open('pyvenv.cfg','rb').read()))"`; look for \x0b, \x0c, \x1c-\x1e, \x85, \u2028, \u2029.
- Determine how the pyvenv.cfg values were produced, and identify whether the venv destination path was derived from untrusted or external input.
- Check whether the resolved 'home' or 'include-system-site-packages' keys in the parsed config point to an unexpected location or disable isolation.
Containment
- Quarantine or delete the tampered virtual environment and prevent its python interpreter from being executed until rebuilt.
- Upgrade virtualenv to 21.14.9 or later on all affected hosts and build systems (`pip install --upgrade 'virtualenv>=21.14.9'`).
- Block CI/CD jobs that create virtual environments from untrusted path input until the upgrade is confirmed.
Evidence Collection
- Preserve a byte-exact copy of the suspicious pyvenv.cfg file (hash it with SHA-256 before and after).
- Collect the process creation events for the virtualenv/python invocation that produced the file, including command line and parent process.
- Capture the full environment variables and working directory of the creating process where available.
Escalation Criteria
- !Escalate to IR if the injected config redirects 'home' to a non-standard or writable location indicating a changed interpreter base.
- !Escalate if a tampered environment's python interpreter was subsequently executed in a production pipeline.
- !Escalate if the untrusted input source cannot be identified or appears to originate from an external, attacker-influenced channel.
Investigation Guide
Forensic Artifacts
- >
pyvenv.cfg file bytes and parsed key/value pairs - >
virtualenv/pip version metadata on the host - >
process creation logs for the venv-creating python process - >
filesystem timestamps (btime/mtime) of the virtual environment directory
Tuning Guidance
Baseline the normal prompt values used by your developers and CI systems. If teams legitimately use non-ASCII prompt strings, allowlist those exact byte sequences rather than disabling the rule. Prioritize events where the anomalous characters appear in or adjacent to the 'home' or 'include-system-site-packages' keys, and treat prompt-only occurrences as lower severity. After confirming all build hosts run virtualenv >= 21.14.9, convert this rule to a low-severity monitoring control.
Hunting Queries
Hunt across endpoints for any pyvenv.cfg containing anomalous Unicode line-boundary characters that str.splitlines() would split on.
// df00tech DF00-2ec4c2eb68 · https://df00tech.com/detections/CVE-2026-113715 · licence: https://df00tech.com/detections/licence
DeviceFileEvents | where FileName =~ "pyvenv.cfg" | extend c = tostring(AdditionalFields) | where c matches regex @"[\x0b\x0c\x1c-\x1e\x85]" | project Timestamp, DeviceName, FolderPath, InitiatingProcessCommandLine ``` df00tech DF00-2ec4c2eb68 · https://df00tech.com/detections/CVE-2026-113715 · licence: https://df00tech.com/detections/licence ```
index=endpoint file_name=pyvenv.cfg | regex _raw="[\x0b\x0c\x1c-\x1e\x85]" | table _time host file_path user Atomic Red Team Tests
Writes a pyvenv.cfg whose prompt value contains a U+000B that str.splitlines() treats as a separator, injecting an overriding include-system-site-packages key.
Command
printf 'home = /usr/bin\nprompt = demo\x0binclude-system-site-packages = true\nversion = 3.12.0\n' > /tmp/atomic_venv/pyvenv.cfg && python3 -c "print(open('/tmp/atomic_venv/pyvenv.cfg').read().splitlines())" Cleanup
rm -rf /tmp/atomic_venv Expected Telemetry
File creation event for /tmp/atomic_venv/pyvenv.cfg containing a 0x0b byte.
Expected Detection
KQL/SPL content rules match the 0x0b character in pyvenv.cfg.
Writes a pyvenv.cfg using a NEL character to inject a 'home' key override consistent with the str.splitlines() parsing divergence.
Command
mkdir -p /tmp/atomic_venv2 && printf 'prompt = x\xc2\x85home = /tmp/evilpy\nversion = 3.12.0\n' > /tmp/atomic_venv2/pyvenv.cfg Cleanup
rm -rf /tmp/atomic_venv2 Expected Telemetry
File creation event for pyvenv.cfg containing the UTF-8 encoded NEL sequence 0xC2 0x85.
Expected Detection
Content regex rules flag the \x85 line-boundary character in pyvenv.cfg.
Installs a virtualenv version in the vulnerable range to validate version-based detection and inventory hunting.
Command
py -m pip install "virtualenv==20.25.0" && py -m virtualenv --version Cleanup
py -m pip install "virtualenv>=21.14.9" Expected Telemetry
Process creation and pip install events recording virtualenv 20.25.0.
Expected Detection
Version inventory hunt identifies a virtualenv install in the >=20.0.0,<21.14.9 vulnerable range.
Writes a pyvenv.cfg with a form-feed (U+000C) separating an injected base-executable override, validating detection on macOS endpoints.
Command
mkdir -p /tmp/atomic_venv3 && printf 'prompt = y\x0cbase-executable = /tmp/evil/python3\nversion = 3.12.0\n' > /tmp/atomic_venv3/pyvenv.cfg Cleanup
rm -rf /tmp/atomic_venv3 Expected Telemetry
File creation event for pyvenv.cfg containing a 0x0c byte.
Expected Detection
Content rules match the form-feed character in pyvenv.cfg.