Advisory

GHSA-xjw2-6jm9-rf67

Also known as: CVE-2023-41039, PYSEC-2023-159

Summary

Sandbox escape via various forms of "format".

Details

Impact
Python's "format" functionality allows someone controlling the format string to "read" all objects accessible through recursive attribute lookup and subscription from objects he can access. This can lead to critical information disclosure.
With RestrictedPython, the format functionality is available via the format and format_map methods of str (and unicode) (accessed either via the class or its instances) and via string.Formatter.
All known versions of RestrictedPython are vulnerable.

Patches
The issue will be fixed in 5.4 and 6.2.

Workarounds
There are no workarounds to fix the issue without upgrading.

References

  • https://docs.python.org/3/library/stdtypes.html#str.format_map
  • http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
  • https://www.exploit-db.com/exploits/51580

For more information

If you have any questions or comments about this advisory:

Credits

Thanks for analysing and reporting the go to:

  • Abhishek Govindarasu
  • Ankush Menat
  • Ward Theunisse

Severity

High Basis: The source's own band: HIGH

Dates

Published
2023-08-30 20:47 UTC
Modified
2024-02-16 08:18 UTC

Affected packages and fixes

restrictedpython

PyPI · All systems

Affected

  • introduced 0, fixed 5.4 (ecosystem)

Fixed versions

5.4

Fix

  • Fixed version 5.4
    pip install --upgrade restrictedpython==5.4

restrictedpython

PyPI · All systems

Affected

  • introduced 6.0, fixed 6.2 (ecosystem)

Fixed versions

6.2

Fix

  • Fixed version 6.2
    pip install --upgrade restrictedpython==6.2

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences