FicklingMLUnpickler Shallow-Copies ML_ALLOWLIST
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning, security
Research direction
Start in fickling/ml.py: FicklingMLUnpickler.__init__ builds its allowlist with dict(ML_ALLOWLIST), which leaves the inner per-module dicts shared with the global. Read how also_allow mutates those inner dicts, then reproduce with the snippet in the issue to confirm collections.Counter leaks into ML_ALLOWLIST. Pick one of the two proposed fixes (deep copy on init, or copy-on-write), add a regression test proving a second unpickler does not see the first one's also_allow entries, and run the ML test suite. Done means the global ML_ALLOWLIST and other unpicklers are unchanged after an instance allows something extra.
Written by the indexing model from the issue text.
Description
When an unpickler instance is created, FicklingMLUnpickler.init copies ML_ALLOWLIST using dict(ML_ALLOWLIST), which is a shallow copy. The per-module inner dicts are still shared with the global. So when also_allow is used to expand the allowlist for a module already in ML_ALLOWLIST, the global dict is altered instead of a local copy, this causes all unpicklers and even the scanner to unintentionally allowlist it.
Tested and reproduced on the latest commit on the master branch.
import io
from fickling.ml import FicklingMLUnpickler, ML_ALLOWLIST
print("Before:", "Counter" in ML_ALLOWLIST.get("collections", {}))
_ = FicklingMLUnpickler(io.BytesIO(b""), also_allow=["collections.Counter"])
print("After :", "Counter" in ML_ALLOWLIST.get("collections", {}))
Initially reported this as a security disclosure but was instructed to report as a public issue instead.
Possible fixes:
1: Just changing the copying to a deep copy, so each unpickler has its own instance of the allowlist
2: Copy on write, so we do a deepcopy of the allowlist only when its altered
Lmk which one sounds better :)
- Dominant language
- Python
- Stars
- 678
- Forks
- 89
- Avg merge
- 41m
- Merged PRs (30d)
- 14
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from trailofbits/fickling
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
trailofbits/fickling#346 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
trailofbits/fickling#322 · 3 comments ·
Maintainers usually reply within 1 day
-
stdlib check depends on the scanner's Python versionPossibly taken @thomas-chauchefoin-tob claimed this 117 days ago. Open
trailofbits/fickling#311 · 1 assignee ·
Maintainers usually reply within 1 day
-
Further align the CLI and Python APIPossibly taken @dguido claimed this 305 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
trailofbits/fickling#101 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
trailofbits/fickling#97 · 1 comment ·
Maintainers usually reply within 1 day
All issues in trailofbits/fickling
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
UKGovernmentBEIS/inspect_ai#6733 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ProyectoRespira/respira-webapp#334 ·
Maintainers usually reply within 1 day
-
bug security-alert
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
spectrayan/carefold#391 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Jakeschincariol/instagram-agent-skill#83 ·
Maintainers usually reply within 10 days
-
Difficulty 1/5 Under an hour Newbie friendliness 64/100