Skip to content
Memory corruption Advisory Advanced CVE-2021-27219

GHSL-2021-045: Integer Overflow in GLib - CVE-2021-27219

An integer overflow in GLib's g_bytes_new function causes it to allocate a smaller buffer than the requested size, potentially leading to memory corruption. The provided proof-of-concept only triggers a crash in a SUID binary, and no exploitable attack vector is currently known.

kevinbackhouse Follow

Originally disclosed on GitHub Security Lab

The function gbytesnew has an integer overflow due to an implicit cast from 64 bits to 32 bits. The overflow could potentially lead to a memory corruption vulnerability.

kevinbackhouse, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely an implicit cast from 64-bit gsize to 32-bit guint in the call to g_memdup, causing truncation of the size argument.

Impact

The proof-of-concept only causes a harmless crash; the report states that no exploitable attack vector is currently known, but memory corruption could potentially lead to code execution.

What the attacker needed

Valid user password; local access to run the poc

The fix

The issue was fixed by merging a change that likely corrects the integer type mismatch.

How it was found

  1. Compile the proof-of-concept program.
  2. Run the program with a username argument.
  3. Enter the user's password when prompted.
  4. The program sends a 4GB cookie to polkit-agent-helper-1, triggering the overflow and an assertion failure.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A function that creates a data buffer mistakenly uses a smaller number type for the size, so a very large size wraps around to a small value. This makes the program think it has a huge buffer when it actually has a tiny one, which could let an attacker write past the end and corrupt memory. The report only shows a crash, not full exploitation.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by kevinbackhouse

View all

47 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.