Real CVEs: Node2Shell (CVE-2026-111497), October 2026
Real CVEMemory safetyIntermediate+87 -0
Click a line to select it, or press and drag down the changes to select a block (Shift-click works too).Tap a line to select it. To select a block, tap its first line, then its last. Then name the weakness and submit the finding. Each finding is marked as soon as you submit it. On the keyboard, Tab to a file's changes, move with the arrow keys, hold Shift to select a block, and press Enter to flag it.
| @@ -1177,0 +1177,45 @@ | |||
| 1177 | + | /* Decodes a command or literal and updates block type ring-buffer. | |
|---|---|---|---|
| 1178 | + | Reads 3..54 bits. */ | |
| 1179 | + | static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength( | |
| 1180 | + | int safe, BrotliDecoderState* s, int tree_type) { | |
| 1181 | + | brotli_reg_t max_block_type = s->num_block_types[tree_type]; | |
| 1182 | + | const HuffmanCode* type_tree = &s->block_type_trees[ | |
| 1183 | + | tree_type * BROTLI_HUFFMAN_MAX_SIZE_258]; | |
| 1184 | + | const HuffmanCode* len_tree = &s->block_len_trees[ | |
| 1185 | + | tree_type * BROTLI_HUFFMAN_MAX_SIZE_26]; | |
| 1186 | + | BrotliBitReader* br = &s->br; | |
| 1187 | + | brotli_reg_t* ringbuffer = &s->block_type_rb[tree_type * 2]; | |
| 1188 | + | brotli_reg_t block_type; | |
| 1189 | + | if (max_block_type <= 1) { | |
| 1190 | + | return BROTLI_FALSE; | |
| 1191 | + | } | |
| 1192 | + | ||
| 1193 | + | /* Read 0..15 + 3..39 bits. */ | |
| 1194 | + | if (!safe) { | |
| 1195 | + | block_type = ReadSymbol(type_tree, br); | |
| 1196 | + | s->block_length[tree_type] = ReadBlockLength(len_tree, br); | |
| 1197 | + | } else { | |
| 1198 | + | BrotliBitReaderState memento; | |
| 1199 | + | BrotliBitReaderSaveState(br, &memento); | |
| 1200 | + | if (!SafeReadSymbol(type_tree, br, &block_type)) return BROTLI_FALSE; | |
| 1201 | + | if (!SafeReadBlockLength(s, &s->block_length[tree_type], len_tree, br)) { | |
| 1202 | + | s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE; | |
| 1203 | + | BrotliBitReaderRestoreState(br, &memento); | |
| 1204 | + | return BROTLI_FALSE; | |
| 1205 | + | } | |
| 1206 | + | } | |
| 1207 | + | ||
| 1208 | + | if (block_type == 1) { | |
| 1209 | + | block_type = ringbuffer[1] + 1; | |
| 1210 | + | } else if (block_type == 0) { | |
| 1211 | + | block_type = ringbuffer[0]; | |
| 1212 | + | } else { | |
| 1213 | + | block_type -= 2; | |
| 1214 | + | } | |
| 1215 | + | if (block_type >= max_block_type) { | |
| 1216 | + | block_type -= max_block_type; | |
| 1217 | + | } | |
| 1218 | + | ringbuffer[0] = ringbuffer[1]; | |
| 1219 | + | ringbuffer[1] = block_type; | |
| 1220 | + | return BROTLI_TRUE; | |
| 1221 | + | } | |
| @@ -1255,0 +1255,19 @@ | |||
| 1255 | + | /* Decodes the block type and updates the state for literal context. | |
| 1256 | + | Reads 3..54 bits. */ | |
| 1257 | + | static BROTLI_INLINE BROTLI_BOOL DecodeLiteralBlockSwitchInternal( | |
| 1258 | + | int safe, BrotliDecoderState* s) { | |
| 1259 | + | if (!DecodeBlockTypeAndLength(safe, s, 0)) { | |
| 1260 | + | return BROTLI_FALSE; | |
| 1261 | + | } | |
| 1262 | + | PrepareLiteralDecoding(s); | |
| 1263 | + | return BROTLI_TRUE; | |
| 1264 | + | } | |
| 1265 | + | ||
| 1266 | + | static void BROTLI_NOINLINE DecodeLiteralBlockSwitch(BrotliDecoderState* s) { | |
| 1267 | + | DecodeLiteralBlockSwitchInternal(0, s); | |
| 1268 | + | } | |
| 1269 | + | ||
| 1270 | + | static BROTLI_BOOL BROTLI_NOINLINE SafeDecodeLiteralBlockSwitch( | |
| 1271 | + | BrotliDecoderState* s) { | |
| 1272 | + | return DecodeLiteralBlockSwitchInternal(1, s); | |
| 1273 | + | } | |
| @@ -1943,0 +1943,11 @@ | |||
| 1943 | + | #define BROTLI_SAFE(METHOD) \ | |
| 1944 | + | { \ | |
| 1945 | + | if (safe) { \ | |
| 1946 | + | if (!Safe##METHOD) { \ | |
| 1947 | + | result = BROTLI_DECODER_NEEDS_MORE_INPUT; \ | |
| 1948 | + | goto saveStateAndReturn; \ | |
| 1949 | + | } \ | |
| 1950 | + | } else { \ | |
| 1951 | + | METHOD; \ | |
| 1952 | + | } \ | |
| 1953 | + | } | |
| @@ -2061,0 +2061,9 @@ | |||
| 2061 | + | do { | |
| 2062 | + | if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) { | |
| 2063 | + | goto NextLiteralBlock; | |
| 2064 | + | } | |
| 2065 | + | brotli_reg_t literal; | |
| 2066 | + | if (!SafeReadSymbol(s->literal_htree, br, &literal)) { | |
| 2067 | + | result = BROTLI_DECODER_NEEDS_MORE_INPUT; | |
| 2068 | + | goto saveStateAndReturn; | |
| 2069 | + | } | |
| @@ -2332,0 +2332,3 @@ | |||
| 2332 | + | NextLiteralBlock: | |
| 2333 | + | BROTLI_SAFE(DecodeLiteralBlockSwitch(s)); | |
| 2334 | + | goto CommandInner; | |
This challenge is Training Content. We encourage you to discuss it and to publish your own write-ups and videos of it. See the terms of service.
Opens in a new tab.