pySCG: Avoid pickle in most cases or at least warn

Offen
#4 18 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
54/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
python

Rechercherichtung

Start by finding the guide section that discusses pickle and compare its guidance with the linked Python documentation and the issue’s examples of safer alternatives. Add a clear warning about unpickling untrusted data and list practical alternatives or protections; done when readers can identify the risk and see safer options. The issue does not name a specific file or test.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

The Python3 pickle documentation says the following:

The pickle module is not secure. Only unpickle data you trust. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never unpickle data that could have come from an untrusted source, or that could have been tampered with. Consider signing data with hmac if you need to ensure that it has not been tampered with. Safer serialization formats such as json may be more appropriate if you are processing untrusted data. See Comparison with json.

However, many researchers and developers are quite clueless about the problem. Paws in the Pickle Jar: Risk & Vulnerability in the Model-sharing Ecosystem reports that, "Our analysis shows that more than 80% of the evaluated machine learning models in the ecosystem consist of pickle-serialized code, which is vulnerable to code injection / arbitrary code execution risks... The pickle module serializes the underlying source code into a byte stream that can’t be statically interpreted back to its true intention and functionality. This requires the user to implicitly trust the contents of the model file uploaded by the author. For this reason, HuggingFace encourages safe tensors as a replacement for PyTorch models, and Splunk supports import of ONNX-formatted models".

Providing a clear note about the problem, and listing several solutions, would be a big help.

Vorherrschende Sprache
Python
Sterne
2
Forks
2
Ø Merge
11 Min.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ossf/python-secure-coding-guide

Alle Issues in ossf/python-secure-coding-guide

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.