common: find_tlv composite DO parsing may cause out-of-bounds access
Closed, ResolvedPublic

Assigned To
Authored By
• gniibe
Tue, Sep 22, 7:56 AM

Description

When composite DO is parsed by find_tlv function, the original buffer length is ignored to call do_find_tlv recursively, but it uses the (claimed) length of the composite DO. This may be wrong.

From the original report:

If there is a composite object whose declared length exceeds the response, the parser returns a pointer that goes beyond the end of the response buffer and the length declared by the attacker.

When scdaemon registers a card application (in app_new_register in scd/app.c), it parses the GDO serial number using find_tlv_unchecked, which consumes a pointer.
If the caller’s check results in an underflow, a large memmove operation is performed into a short response buffer on the heap.
As a result, a heap corruption occurs in the user’s scdaemon process.
An attacker only needs to provide a card or token; no PIN or other credentials are required.

Reported-by: eris <security [at] eris.rs>

Revisions and Commits

Event Timeline

• gniibe triaged this task as High priority.
• gniibe created this task.
• gniibe changed the task status from Open to Testing.Tue, Sep 22, 9:51 AM
• werner shifted this object from the Restricted Space space to the S1 Public space.Tue, Sep 22, 12:06 PM
• werner changed the visibility from "g10code (Project)" to "Public (No Login Required)".
• werner changed the edit policy from "Custom Policy" to "Contributor (Project)".
• werner moved this task from WIP to QA on the gnupg26 board.
• werner updated the task description. (Show Details)
• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Sep 28, 2:25 AM