-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
Out-of-bounds read in the ISO-2022 decoder for an unknown charset #153603
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Bug report
Bug description:
The C implementation of the ISO-2022 decoders scans a designation table for the
charset held in the decoder state, but the loop's terminator is compiled only
under
Py_DEBUG. On a release build, decoding after an unknown charset is setvia
setstate()walks off the table (an out-of-bounds read) and dereferences agarbage function pointer.
import codecs
d = codecs.getincrementaldecoder("iso-2022-jp")()
d.setstate((b"", 0xff))
d.decode(b"!", final=True) # out-of-bounds read / crash
CPython versions tested on:
3.13, 3.14, 3.15, 3.16
Operating systems tested on:
macOS
Linked PRs