Variant analysis: 1 unfixed sibling safety gap in protobuf

Open
#30,183 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@JasonLunn is already working on this.

Since Oct 6, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
security

Research direction

Start in third_party/upb/upb/hash/common.c and compare the listed copy, clear, and compact allocation sites with upb_strtable_init() and its existing upb_MulOverflow() usage. Review the upb hash-table code and the protobuf_protobuf_fuzzer harness first. Done means the sibling allocation paths handle overflow consistently and the relevant parser or fuzzing checks pass.

Written by the indexing model from the issue text.

Description

bug c++

Summary

Variant analysis of historical fixes in protobuf identified 1 code site where an integer-overflow guard, bounds check, or safe-allocation wrapper exists at one location but is missing at a structurally identical sibling location (same file, same function, or same pattern family) elsewhere in the codebase.

Each finding below is code-confirmed against the current HEAD (verified by cloning the repository fresh and checking the pattern is still present), with the exact file/line locations, the root cause, a description of the trigger path, and — where available — ASan/execution verification output or a proof-of-concept.

Note on origin: these were surfaced by an automated variant-analysis pipeline that diffs historical fix commits against sibling code paths, then has each candidate manually reviewed. I'm posting them together per-project rather than as separate issues to respect maintainer time. Happy to split, close, or reprioritize any of these as you see fit.


Finding 1: protobuf — upb_strtable_copy() missing overflow check (sibling of upb_strtable_init() fix in c6b856d)

Verified against HEAD: 99f6640631b66b52853278f631226da808e8c9f6 (2026-09-25)

*- Project: protobuf (protocolbuffers/protobuf, upb C micro-library)

  • Class: Heap-buffer-overflow write (via integer overflow in allocation size for hash table copy)
  • Status: Code-confirmed, exec-blocked
  • Sibling of: Fix commit c6b856d — converted upb_strtable_init() and ~15 other allocation sites to use upb_MulOverflow() for overflow-safe multiplication*

Discovery method

Variant analysis. Commit c6b856d was a large overflow-check overhaul that converted ~15 table_size * sizeof(T) patterns to use upb_MulOverflow() — a function that returns false on overflow instead of wrapping. Three sites in the same files were missed: upb_strtable_copy(), and two table clear functions.

Vulnerable code

third_party/upb/upb/hash/common.c

FIXED — upb_strtable_init() after c6b856d:

// SAFE:
size_t bytes;
if (!upb_MulOverflow(t->table_size, sizeof(upb_tabent), &bytes))
    return false;
t->entries = upb_gmalloc(bytes);

UNFIXED siblings:

  1. upb_strtable_copy() at line 601:
// VULNERABLE — no overflow check:
t->entries = upb_gmalloc(t->table_size * sizeof(upb_tabent));
  1. upb_inttable_clear() at line 561:
// VULNERABLE:
upb_inttable_clear(t, upb_gmalloc(t->table_size * sizeof(upb_tabent)));
  1. upb_strtable_clear() at line 747:
// VULNERABLE:
upb_strtable_clear(t, upb_gmalloc(t->table_size * sizeof(upb_tabent)));
  1. upb_strtable_compact() at line 1023:
// VULNERABLE:
upb_strtable_clear(t, upb_gmalloc(t->table_size * sizeof(upb_tabent)));

Root cause

The overflow-check overhaul (c6b856d) was thorough but mechanically incomplete — it converted init() functions across the hash table module but missed copy(), clear(), and compact() functions that use the identical table_size * sizeof(T) pattern. The init() and copy() functions are literally adjacent in the source file.

Trigger path

  1. Crafted protobuf binary with a deeply nested or large-repeated message
  2. → Deserialization triggers string table reallocation (upb_strtable_copy / upb_strtable_compact)
  3. → Large table_size (e.g., ~2³¹ on 32-bit) → multiplication wraps → undersized allocation → heap overflow write when entries are inserted

Fuzz harness: protobuf_protobuf_fuzzer (an OSS-Fuzz/fuzzbench harness) — exercises protobuf parsing including the upb runtime.

Sibling-gap quality

Excellent. Same file (hash/common.c), same multiplication pattern (table_size * sizeof(T)), same upb_MulOverflow() API that was already used to fix init()`. Three sibling functions missed within the same translation unit.


Analysis date: 2026-09-22. Code-confirmed, not execution-verified.


Methodology

For each historical vulnerability fix in the codebase, we identified the safe pattern the fix introduced (an overflow guard, a safe allocator wrapper, a bounds check) and searched the rest of the codebase for structurally identical code that predates or postdates the fix but never received it. Each candidate was then manually verified against the current HEAD listed above.

Happy to provide anything else that would help triage — additional PoC inputs, a minimal patch following the existing safe-sibling pattern, or a written reproduction script.

Dominant language
C++
Stars
72.2k
Forks
16.4k
Avg merge
1d 8h
Merged PRs (30d)
342

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from protocolbuffers/protobuf

All issues in protocolbuffers/protobuf

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.