37
Run-time firmware integrity verification: what if you can’t trust your network card? International Symposium on Recent Advances in Intrusion Detection Menlo Park, September 2011 Loïc Duflot, Yves-Alexis Perez, Benjamin Morin ANSSI French Network and Information Security Agency [email protected]

What if you can’t trust your network card? (slides)

Embed Size (px)

DESCRIPTION

International Symposium on Recent Advances in Intrusion Detection, Menlo Park, September 2011, by Loïc Duflot, Yves-Alexis Perez, Benjamin Morin (ANSSI, French Network and Information Security Agency). This document is available from the website of its authors at: http://www.ssi.gouv.fr/IMG/pdf/slides-raid11.pdf The whole paper is available from: http://www.ssi.gouv.fr/IMG/pdf/paper.pdf

Citation preview

Page 1: What if you can’t trust your network card? (slides)

Run-time firmware integrity verification:what if you can’t trust your network card?

International Symposium on Recent Advances in Intrusion DetectionMenlo Park, September 2011

Loïc Duflot, Yves-Alexis Perez, Benjamin Morin

ANSSIFrench Network and Information Security Agency

[email protected]

Page 2: What if you can’t trust your network card? (slides)

Introduction

Embedded devices

I Embedded systems are increasingly prevalent in computersI Network cards, hard drive controllers, chipsets, basebands, etc.I Some have high processing capabilities (“smart” devices)I They act as black-box execution environments

I They constitute a potential threat for the platforms’ securityI They have access to sensitive informationI They generally lack the protections available on standard proces-

sors (e.g., an MMU)I They potentially run with high privileges w.r.t the main operating

system

ANSSI – French Network and Information Security Agency 2/26

Page 3: What if you can’t trust your network card? (slides)

Introduction

Attacks against embedded devices

I Vulnerabilities were found in several embedded software and firmwarein the past few years :

Basebands Weinmann [13]Network controllers Duflot and Perez [4], Triulzi [12], Delugré [3]

Keyboard controllers Chen [2], Gazet [6]Chipsets Ortega and Sacco [9]

I Defending a system against such attacks is difficult because firmwareare running out of the scope of the operating system.

I Existing IDSes have probably overlooked these attacksI they mainly monitor the operating system and applicationsI those attacks are still quite new

ANSSI – French Network and Information Security Agency 3/26

Page 4: What if you can’t trust your network card? (slides)

Introduction

Example from our own proof-of-concept attack

I In [4], we demonstrated how it is possible for an attacker to takefull control of a computer

I by exploiting a vulnerability in the network adapter, andI adding a back-door in the OS kernel using DMA accesses ;I the back-door opens a reverse shell when the kernel processes an

ICMP message with a particular type.I Our proof-of-concept attack was based on a real world vulnera-

bilityI the vulnerability lied in the ASF remote administration function of

the network adapter of the target machine.I it was unconditionally exploitable when the ASF function was acti-

vated to any attacker that would be able to send UDP packets tothe machine.

ANSSI – French Network and Information Security Agency 4/26

Page 5: What if you can’t trust your network card? (slides)

Problem statement

Problems & existing solutionsCompromised device?

Consequences

system I full OS compromiseI rootkit re-injection at startup

platform I attacks against other devices on the same buses [11]network I silent data leak

I stepping stone to attack the whole network silentlyI won’t be blocked by firewalls on vulnerable machines

Counter-measuressystem I I/O MMU (Intel Vt-d and AMD IOMMU)

platform I PCI Express Access Control Servicesnetwork I ?

ANSSI – French Network and Information Security Agency 5/26

Page 6: What if you can’t trust your network card? (slides)

Problem statement

Problems & existing solutionsCompromised device?

Consequences

system I full OS compromiseI rootkit re-injection at startup

platform I attacks against other devices on the same buses [11]

network I silent data leakI stepping stone to attack the whole network silentlyI won’t be blocked by firewalls on vulnerable machines

Counter-measuressystem I I/O MMU (Intel Vt-d and AMD IOMMU)

platform I PCI Express Access Control Services

network I ?

ANSSI – French Network and Information Security Agency 5/26

Page 7: What if you can’t trust your network card? (slides)

Problem statement

Problems & existing solutionsCompromised device?

Consequences

system I full OS compromiseI rootkit re-injection at startup

platform I attacks against other devices on the same buses [11]network I silent data leak

I stepping stone to attack the whole network silentlyI won’t be blocked by firewalls on vulnerable machines

Counter-measuressystem I I/O MMU (Intel Vt-d and AMD IOMMU)

platform I PCI Express Access Control Servicesnetwork I ?

ANSSI – French Network and Information Security Agency 5/26

Page 8: What if you can’t trust your network card? (slides)

Problem statement

Firmware integrity checks

We need to check the firmware’s integrityI At load time

I Peripherals’ firmware should be measured during a trusted bootI This can be achieved by means of a TPM

I At runtimeI Our objective is to check that the firmware is running untamperedI The operating system acts as the verifier of the network card’s ex-

ecutionI We assume that the operating system is trusted

ANSSI – French Network and Information Security Agency 6/26

Page 9: What if you can’t trust your network card? (slides)

Problem statement

Existing solutions

Remote firmware attestation [7, 8] ?I Based on a challenge-response protocol

I The target computes a checksum over its entire memoryI The verifier checks the correctness of the returned checksum

I Remote firmware attestation is difficult [1, 10, 5]I Severe constraints imposed by the checksum function executionI Is it really suitable for a network card?

Software symbiotes ?I might be an interesting solution, requires further investigationsI seems quite intrusive

..

ANSSI – French Network and Information Security Agency 7/26

Page 10: What if you can’t trust your network card? (slides)

Problem statement

Existing solutions

Remote firmware attestation [7, 8] ?I Based on a challenge-response protocol

I The target computes a checksum over its entire memoryI The verifier checks the correctness of the returned checksum

I Remote firmware attestation is difficult [1, 10, 5]I Severe constraints imposed by the checksum function executionI Is it really suitable for a network card?

Software symbiotes ?I might be an interesting solution, requires further investigationsI seems quite intrusive

..

ANSSI – French Network and Information Security Agency 7/26

Page 11: What if you can’t trust your network card? (slides)

Problem statement

Existing solutions

Remote firmware attestation [7, 8] ?I Based on a challenge-response protocol

I The target computes a checksum over its entire memoryI The verifier checks the correctness of the returned checksum

I Remote firmware attestation is difficult [1, 10, 5]I Severe constraints imposed by the checksum function executionI Is it really suitable for a network card?

Software symbiotes ?I might be an interesting solution, requires further investigationsI seems quite intrusive

..

ANSSI – French Network and Information Security Agency 7/26

Page 12: What if you can’t trust your network card? (slides)

Problem statement

Existing solutions

Remote firmware attestation [7, 8] ?I Based on a challenge-response protocol

I The target computes a checksum over its entire memoryI The verifier checks the correctness of the returned checksum

I Remote firmware attestation is difficult [1, 10, 5]I Severe constraints imposed by the checksum function executionI Is it really suitable for a network card?

Software symbiotes ?I might be an interesting solution, requires further investigationsI seems quite intrusive

..

ANSSI – French Network and Information Security Agency 7/26

Page 13: What if you can’t trust your network card? (slides)

Embedded device intrusion detection approach

What is a network card?

Quite simple in theoryI transfer ethernet frames from the host to the wireI and vice versa

Increasingly complex in practice...I advanced capabilities (PXE, TSO...)I platform administration functionsI active even when OS is down or absentI runs a firmware on embedded CPU

ANSSI – French Network and Information Security Agency 8/26

Page 14: What if you can’t trust your network card? (slides)

Embedded device intrusion detection approach

What is (graphically) a network card?

ANSSI – French Network and Information Security Agency 9/26

Page 15: What if you can’t trust your network card? (slides)

Embedded device intrusion detection approach

Intrusion detection model

I Our detection method is anomaly-basedI The model of normal behavior is based on the NIC’s memory layoutI The memory profile is built empirically, by means of the observed

NIC’s memory accesses during “normal” network sessionsI Memory areas used to execute code, read and/or write data are

distinguished in the modelI The card in run in step-by-step (debug) mode during detectionI Any memory access that is outside the NIC’s memory profile is

interpreted as an attempt to divert the firmware’s control flowI Heuristics used to detect anomalous memory accesses

I Step-by-step instruction comparisonI Step-by-step instruction address checkingI Shadow return stack

ANSSI – French Network and Information Security Agency 10/26

Page 16: What if you can’t trust your network card? (slides)

Embedded device intrusion detection approach

Detection heuristics (1/2)

Step-by-step instruction comparisonI Basically consists in checking that the instruction that is to be

run is the same as the reference model’s oneI This technique only works if the code is not self modifying (which

is the case for the firmware we are considering)

Step-by-step address checkingI Basically consists in checking that the instruction pointer value is

consistentI The network card running code in the heap, in the stack or in the

memory scratchpad is indicative of an anomaly

ANSSI – French Network and Information Security Agency 11/26

Page 17: What if you can’t trust your network card? (slides)

Embedded device intrusion detection approach

Detection heuristics (2/2)

Shadow call stackI Basically consists in maintaining a copy of the call stack of the

firmware on the host sideI On an identified CALL-like instruction, the return address is pushed

on the shadow stackI On an identified RET-like instruction, the return address is checked

against the saved one

Other heuristics (not implemented)I Another heuristic could consist in searching for anything that

meets the statistical profile of executable code in data areaI This detection technique is prone to false positives

ANSSI – French Network and Information Security Agency 12/26

Page 18: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Network Adapter Verification and Integrity checking SolutionWe designed our verification framework, NAVIS

I based on card instrumentationI implements detection heuristicsI prevents control flow modifications

We used:I Broadcom BCM5754 and BCM5755M network cardsI ASF firmware

Preventing confusion:From now on:

CPU is the main CPU on the motherboard, running the OSMIPS is the management processor on the network controller

ANSSI – French Network and Information Security Agency 13/26

Page 19: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Instrumenting the card

I Accessing NIC’s memoryI The NIC’s internal memory is mapped in the main memoryI This mechanism provides access to the firmware running on the NIC

I Identifying memory areasI Broadcom docs and drivers reveal that firmware files have three

areas (text, data, rodata)I But they do not provide the mappings for these areaI The mappings can be identified by tracking the MIPS activity

I NIC’s internal registersI state, control and breakpoint registers are accessible from the host

..This allows us to monitor the activity of the firmware, detectanomalous behaviours and stop the adapter when a problem isdetected

ANSSI – French Network and Information Security Agency 14/26

Page 20: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Instrumenting the card

I Accessing NIC’s memoryI The NIC’s internal memory is mapped in the main memoryI This mechanism provides access to the firmware running on the NIC

I Identifying memory areasI Broadcom docs and drivers reveal that firmware files have three

areas (text, data, rodata)I But they do not provide the mappings for these areaI The mappings can be identified by tracking the MIPS activity

I NIC’s internal registersI state, control and breakpoint registers are accessible from the host

..

This allows us to monitor the activity of the firmware, detectanomalous behaviours and stop the adapter when a problem isdetected

ANSSI – French Network and Information Security Agency 14/26

Page 21: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Instrumenting the card

I Accessing NIC’s memoryI The NIC’s internal memory is mapped in the main memoryI This mechanism provides access to the firmware running on the NIC

I Identifying memory areasI Broadcom docs and drivers reveal that firmware files have three

areas (text, data, rodata)I But they do not provide the mappings for these areaI The mappings can be identified by tracking the MIPS activity

I NIC’s internal registersI state, control and breakpoint registers are accessible from the host

..This allows us to monitor the activity of the firmware, detectanomalous behaviours and stop the adapter when a problem isdetected

ANSSI – French Network and Information Security Agency 14/26

Page 22: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Instrumenting the card

I Accessing NIC’s memoryI The NIC’s internal memory is mapped in the main memoryI This mechanism provides access to the firmware running on the NIC

I Identifying memory areasI Broadcom docs and drivers reveal that firmware files have three

areas (text, data, rodata)I But they do not provide the mappings for these areaI The mappings can be identified by tracking the MIPS activity

I NIC’s internal registersI state, control and breakpoint registers are accessible from the host

..This allows us to monitor the activity of the firmware, detectanomalous behaviours and stop the adapter when a problem isdetected

ANSSI – French Network and Information Security Agency 14/26

Page 23: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Instrumenting the card

I Accessing NIC’s memoryI The NIC’s internal memory is mapped in the main memoryI This mechanism provides access to the firmware running on the NIC

I Identifying memory areasI Broadcom docs and drivers reveal that firmware files have three

areas (text, data, rodata)I But they do not provide the mappings for these areaI The mappings can be identified by tracking the MIPS activity

I NIC’s internal registersI state, control and breakpoint registers are accessible from the host

..

This allows us to monitor the activity of the firmware, detectanomalous behaviours and stop the adapter when a problem isdetected

ANSSI – French Network and Information Security Agency 14/26

Page 24: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Network controller memory mapcode exec instructions executed by the MIPS

MIPS writes addresses written by the MIPS (SH, SB, SW)MIPS reads addresses read by the MIPS (LH/LHU, LB/LBU, LW)

other writes network packets written to the card memory by DMA from host and by PHY fromthe wire

1

10

100

1000

10000

100000

1e+06

1e+07

1e+08

0x0 0x20000

count

address

R/W/X memory mapping

EXT WCPU XCPU RCPU W

RCBTXring

RXring

TXMBUF RXMBUF scratchpad

cpu stack

ANSSI – French Network and Information Security Agency 15/26

Page 25: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Memory map analysis

External writesI in RX/TX rings . and in the

scratchpad area . (traffic fromand to the main host)

I in unmapped areas... .I inside the MIPS code area! .

1

10

100

1000

10000

100000

1e+06

1e+07

1e+08

0x0 0x20000

count

address

R/W/X memory mapping

EXT WCPU XCPU RCPU W

RCBTXring

RXring

TXMBUF RXMBUF scratchpad

cpu stack

.....

ANSSI – French Network and Information Security Agency 16/26

Page 26: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Memory map analysis

MIPS executionI mostly at the beginning of

scratchpad . plus few instruc-tions at the end .

1

10

100

1000

10000

100000

1e+06

1e+07

1e+08

0x0 0x20000

count

address

R/W/X memory mapping

EXT WCPU XCPU RCPU W

RCBTXring

RXring

TXMBUF RXMBUF scratchpad

cpu stack

...

ANSSI – French Network and Information Security Agency 16/26

Page 27: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Memory map analysis

MIPS reads/writesI in the Rings .Control Blocks

and TXMBUF . (presumably ASF

traffic)I in the scratchpad, with four dif-

ferent areas:I just after the main code area .I in the packets area (presum-

ably ASF traffic) .I just after the MIPS code areaI after the MIPS code area,

just before scrachpad end (thestack) .

1

10

100

1000

10000

100000

1e+06

1e+07

1e+08

0x0 0x20000

count

address

R/W/X memory mapping

EXT WCPU XCPU RCPU W

RCBTXring

RXring

TXMBUF RXMBUF scratchpad

cpu stack

......

ANSSI – French Network and Information Security Agency 16/26

Page 28: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Challenges in monitoring the MIPS

I Control flow instructionsI No CALL/RET instructions on MIPS architectureI Fortunately, the firmware code is rather simpleI Function calls can reliably be inferred from jump instructions (JAL)

and a specific register (R31) used to store return addressesI Interrupts triggered by the network adapter

I Cause unexpected changes in the control flow (looks like an attack)I The firmware uses a single interrupt handler, starting at a fixed

addressI Return from the interrupt vector is done through register R27I Dealing with interrupts is manageable by monitoring this behaviour

ANSSI – French Network and Information Security Agency 17/26

Page 29: What if you can’t trust your network card? (slides)

Prototype implementation : NAVIS

Summarywe know I where the MIPS reads and writes data

I where the MIPS executes codeI how to find function calls and RET

issues I there are external writes to the MIPS code areaI there are writes in unmapped areasI interrupts make it harder to follow control flow

remarks I no way to enforce rodataI no such thing as NX on those MIPS processorI no segmentation/pagination

This allows to detect any unexpected change in the control flowI When a return value is modified on the stackI But data on the stack, heap and scratchpad can still be modified

by the attacker.

ANSSI – French Network and Information Security Agency 18/26

Page 30: What if you can’t trust your network card? (slides)

Experimental results

It works!

We tried the various proof-of-concept attacks we created aspart of previous researches

I they are all detectedI an alert is reported in NAVISI the network controler is stoppedI one can either reset the card and start fresh,I or try to investigate in the debugger

Since we detect control flow modification, other attacks should bedetected as well

ANSSI – French Network and Information Security Agency 19/26

Page 31: What if you can’t trust your network card? (slides)

Experimental results

Performance

I The monitoring is expected to have a negative impact on the NIC’sperformance

I The MIPS CPU is run in step-by-step modeI Various tests are done at each MIPS cycle (bounds, call stack, etc.)I So each MIPS cycle requires many CPU cycles

I Still, performance is not that poorI We still manage to achieve gigabit speed...I ... at the cost of 100% CPU usage on one core (active loop and

context switches)I However, what is really important is

I packets rate and packet lossI when firmware processes packetsI when NAVIS checks are active (ASF traffic)

ANSSI – French Network and Information Security Agency 20/26

Page 32: What if you can’t trust your network card? (slides)

Experimental results

I UDP/9

-2

0

2

4

6

8

10

12

14

0

50000

100000

150000

200000

250000

% pps

CPUInterrupt

#recv

-20

0

20

40

60

80

100

120

0

50000

100000

150000

200000

250000

% pps

I UDP/623

-1

0

1

2

3

4

5

6

7

8

9

0

2000

4000

6000

8000

10000

12000

% pps

CPUInterrupt

#recv

Without Navis

-20

0

20

40

60

80

100

120

0

50

100

150

200

250

300

% pps

With NavisANSSI – French Network and Information Security Agency 21/26

Page 33: What if you can’t trust your network card? (slides)

Conclusion and future work

Limitations of the approach

I The detection model is highly adapter-specific:I we tested on BCM5754 and BCM5755M adaptersI it could be adapted to other Broadcom adapters (provided they use

the same kind of firmwares)I our concept can be ported to other devices as long as similar debug

capabilities are presentI Can an attacker prevent us to control the NIC?I We cannot prevent arbitrary writes in code area (since standard

behavior seems to allow it)I High processing cost

ANSSI – French Network and Information Security Agency 22/26

Page 34: What if you can’t trust your network card? (slides)

Conclusion and future work

ConclusionWe proposed NAVIS, a firmware integrity attestationframework:

I firmware integrity attestation is a (very) hard problemI our proof of concept is highly firmware and adapter specific

NAVIS can detect and prevent most low level attacks on NICfirmware

I But it requires the OS to be trusted.I And protecting the OS stays the highest priority.

If the embedded devices implement more functions, could they havemore protections too?

ANSSI – French Network and Information Security Agency 23/26

Page 35: What if you can’t trust your network card? (slides)

Conclusion and future work

Questions & AnswersThank your for your attention

Do you have any question?

No network cards were harmed in the making of this paper

ANSSI – French Network and Information Security Agency 24/26

Page 36: What if you can’t trust your network card? (slides)

Conclusion and future work

Bibliography I[1] Claude Castelluccia, Aurelien Francillon, Daniele Perito, and Claudio Soriente. On the

difficulty of software-based attestation of embedded devices. In Proceedings of 16th ACMConference on Computer and Communications Security, November 2009.

[2] K. Chen. Reversing and exploiting an apple firmware update. BlackHat, 2009.

[3] Guillaume Delugre. Closer to metal : Reverse ingineering the broadcom netextreme’sfirmware. Hack.lu, 2010.

[4] Loıc Duflot and Yves-Alexis Perez. Can you still trust your network card? CanSecWest,2010.

[5] Aurelien Francillon, Claude Castelluccia, Daniele Perito, and Claudio Soriente. Commentson “refutation of on the difficulty of software based attestation of embedded devices”. -, 2010.

[6] Alexandre Gazet. Sticky fingers & kbc custom shop. -, 2011.

[7] Yanlin Li, Jonathan M. McCune, and Adrian Perrig. SBAP: Software-Based Attestation forPeripherals. In Proceedings of the 3rd International Conference on Trust and TrustworthyComputing (Trust 2010), June 2010.

[8] Yanlin Li, Jonathan M. McCune, and Adrian Perrig. VIPER: Verifying the integrity of pe-ripheral’s firmware. In Proceedings of CCS’11, 2011.

[9] Alfredo Ortega and Anibal Sacco. Deactivate the rootkit. BlackHat, 2009.

ANSSI – French Network and Information Security Agency 25/26

Page 37: What if you can’t trust your network card? (slides)

Conclusion and future work

Bibliography II

[10] Adrian Perrig and Leendert Van Doorn. Refutation of “on the difficulty of software basedattestation of embedded devices”. -, 2010.

[11] Fernand L. Sang, Eric Lacombe, Vincent Nicomette, and Yves Deswarte. Exploiting anI/OMMU vulnerability. In MALWARE ’10: 5th International Conference on Malicious andUnwanted Software, pages 7–14, 2010.

[12] Arrigo Triulzi. Taking NIC backdoors to the next level. CanSecWest, 2010.

[13] Ralf-Philipp Weinmann. All Your Baseband Are Belong To Us. CCC, 2010.

ANSSI – French Network and Information Security Agency 26/26