Page MenuHome GnuPG

Other bugs reported by 49016 et al.
Testing, NormalPublic

Description

  • Integer Truncation of Input Arguments
    • string_to_cipher_algo (for example) uses strtol which returns long but val is an integer
      • opengpg_oid_from_str is another case
  • Integer Overflow in literals_seen

An attacker can craft a message with a compressed packet, which contains >= 2147483648 literal packets, overflowing the counter, and thus allowing multiple plaintext attacks mitigated by this counter to work again.

  • Buffer overflow in stresc in testing file t-stringhelp.c

The function stresc in t-stringhelp.c suffers from an underallocation leading to a heap overflow. Furthermore, the function appears to be logically incorrect. The function seems to only be used in test code, however we still want to point out the bug to avoid future usage in production code. The first loop allocates two output characters per newline input character. However, in the second loop three output characters are written per newline character in the input. Additionally, the newline character itself is written among the output characters raising the question of whether the escaping is done correctly.

  • ANSI Sequences and Other Binary Output gets Written to the Terminal Without Confirmation

ANSI sequences can deceive the user about legitimate program output from *GnuPG* such as log messages, and the message contents. As a security critical tool for end users we recommend *GnuPG* to warn the user before outputting non-printable data (other than common whitespace), e.g., in the fashion of the gzip utility.

  • openpgp_oid_from_str has a wrong memory-safety assumption

The OID -1 would be parsed by strtoul as 4,294,967,295, which would be represented as more than 2 bytes.

It is currently unreachable with user input, but this assumption is wrong and can lead to future memory corruption vulnerabilities.

Event Timeline

gniibe created this object in space Restricted Space.
gniibe created this object with visibility "g10code (Project)".
gniibe created this object with edit policy "g10code (Project)".

For Integer Truncation of Arguments report, since the int value is limited to one-octet value, we could add check for the length of input when we use strtol.

For Integer Overflow in literals_seen, I think that the claim is wrong.
When literals_seen becomes two, GnuPG stops processing to return an error.
It's not possible for GnuPG to keep processing.

For

openpgp_oid_from_str has a wrong memory-safety assumption

The analysis is wrong. Just after strtoul, it has the check with digitp (string); When it's not a digit (minus sign), it returns an error GPG_ERR_INV_OID_STRING correctly.

For t-stringhelp.c, here is a fix.

gniibe triaged this task as Normal priority.
gniibe mentioned this in Unknown Object (Maniphest Task).Nov 10 2025, 2:51 AM
gniibe mentioned this in Unknown Object (Maniphest Task).Nov 17 2025, 8:23 AM
gniibe mentioned this in Unknown Object (Maniphest Task).Nov 24 2025, 6:59 AM
werner renamed this task from Bugs reported to Other bugs reported by 49016 et al..Fri, Dec 26, 3:50 PM
werner shifted this object from the Restricted Space space to the S1 Public space.
werner changed the visibility from "g10code (Project)" to "Public (No Login Required)".

The int-truncation change breaks other things. I noticed this by chance in the interactive mode due to warning noticed. Before we ever do such things again we need to have regression tests for setting preferences. Or manually check everything. Need to do a 2.5.16 tomorrow :-(