]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Add defensive checks to PDF parser for malformed input
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 12 Jan 2026 12:17:32 +0000 (12:17 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 12 Jan 2026 12:17:32 +0000 (12:17 +0000)
commitc1bf0e695413c7fca37123bd53ff42a28d095b09
tree872dbc10c64f11933d086274c1a384468f3c38c2
parentfe2e4211f0ac504d81c14961d241f7a5ab9fba7b
[Fix] Add defensive checks to PDF parser for malformed input

Add pcall wrappers and type checks throughout pdf.lua to handle
malformed PDFs from untrusted sources without crashing:

- Add nil checks for stream objects before accessing fields
- Wrap grammar matches in pcall to catch parsing errors
- Add type validation before ipairs calls on trie match results
- Wrap span extractions in pcall to handle invalid offsets
- Add defensive checks in processor functions (trailer, suspicious)
- Wrap URL creation in pcall for malformed URI strings

Errors are logged via debugm for diagnosis while allowing
processing to continue gracefully.
lualib/lua_content/pdf.lua