Skip to contentSkip to conversation

ccid: Fix buffer overrun in handling of VSC_ATR message

PATCH In review Markus Armbruster 2 participants 3 messages Nov 28, 2011 – Nov 29, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ccid: Fix buffer overrun in handling of VSC_ATR message

ATR size exceeding the limit is diagnosed, but then we merrily use it anyway, overrunning card->atr[].

The message is read from a character device. Obvious security implications unless the other end of the character device is trusted.

Spotted by Coverity. CVE-2011-4111.

---
 hw/ccid-card-passthru.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/ccid-card-passthru.c +1 -0
index 2cbc81b..9f51c6c 100644
@@ -150,6 +150,7 @@ static void ccid_card_vscard_handle_message(PassthruState *card,
             error_report("ATR size exceeds spec, ignoring");
             ccid_card_vscard_send_error(card, scr_msg_header->reader_id,
                                         VSC_GENERAL_ERROR);
+            break;
         }
         memcpy(card->atr, data, scr_msg_header->length);
         card->atr_length = scr_msg_header->length;
Signature · 1 line
1.7.6.4
#1 lore raw
Quoted 8 lines · Markus Armbruster

ATR size exceeding the limit is diagnosed, but then we merrily use it anyway, overrunning card->atr[].

The message is read from a character device. Obvious security implications unless the other end of the character device is trusted.

Spotted by Coverity. CVE-2011-4111.

Anthony, do you want me to do a pull request for this or can you merge it as is?

Alon

Quoted 20 lines
---
 hw/ccid-card-passthru.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/ccid-card-passthru.c +1 -0
index 2cbc81b..9f51c6c 100644
@@ -150,6 +150,7 @@ static void ccid_card_vscard_handle_message(PassthruState *card,
             error_report("ATR size exceeds spec, ignoring");
             ccid_card_vscard_send_error(card, scr_msg_header->reader_id,
                                         VSC_GENERAL_ERROR);
+            break;
         }
         memcpy(card->atr, data, scr_msg_header->length);
         card->atr_length = scr_msg_header->length;
Signature · 1 line
1.7.6.4
#2 lore raw
Quoted 4 lines · Alon Levy
Quoted 3 lines · Markus Armbruster

ATR size exceeding the limit is diagnosed, but then we merrily use it anyway, overrunning card->atr[].

Quoted 8 lines
Quoted 5 lines

The message is read from a character device. Obvious security implications unless the other end of the character device is trusted.

Spotted by Coverity. CVE-2011-4111.

Anthony, do you want me to do a pull request for this or can you merge it as is?

It's already in, commit 7e62255a.