do as i say not as i do stealth modification of ... · •need to focus on system level security of...

59
Do as I Say not as I Do Stealth Modification of Programmable Logic Controllers I/O by Pin Control Attack ALI ABBASI SYSSEC GROUP, RUHR UNIVERSITY BOCHUM, GERMANY & SCS GROUP UNIVERSITY OF TWENTE , NETHERLANDS MAJID HASHEMI PARIS, FRANCE

Upload: others

Post on 13-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

DoasISaynotasIDoStealthModificationof

ProgrammableLogicControllersI/ObyPinControlAttack

ALI ABBASI

SYSSEC GROUP, RUHRUNIVERSITY BOCHUM, GERMANY& SCS GROUPUNIVERSITY OF TWENTE, NETHERLANDS

MAJ ID HASHEMI

PARIS , FRANCE

Page 2: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Whoweare

• AliAbbasi,visitingresearcheratchairofsystemsecurityofRuhrUniversityBochumandPhDstudentatDistributedandEmbeddedSystemsSecurityGroup,UniversityofTwente,TheNetherlands.

(@bl4ckic3)

• MajidHashemi,R&Dresearcher(@m4ji_d).

2

Page 3: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Agenda• BackgroundonProcessControl• Backgroundonexistingattacksanddefensesforembeddedsystems• ApplicableDefensesforPLCs• BackgroundonPinControl• TheProblemwithPinControl• Rootkitvariant• Non-rootkitvariant• Demo• Discussions

3

Page 4: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Whatthistalkisabout?

• ThetalkistryingtouncoverexistingdesignflawinPLCs.

• Theattackcanbeusedinfuturebyattackers.

• WearenotunveilingfullyfunctionalmalwareforPLCs.

• Noexploitationtechniques,no0dayleak

• Wearenotgoingtomentionanyvendorname.

4

Page 5: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

IndustrialControlSystem

Physicalapplication

InformationTechnology(IT)

OperationalTechnology(OT)

5

Page 6: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

IndustrialControlSystemhacking

Physicalapplication 6

Page 7: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Processcontrol101

Page 8: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Processcontrol

Runningupstairstoturnonyourfurnaceeverytimeitgetscoldgetstiringafterawhilesoyouautomateitwithathermostat

Setpoint

8

Page 9: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Controlloop

Actuators

Controlsystem

Physicalprocess Sensors

Measureprocessstate

Computescontrolcommandsfor

actuators

Adjustthemselvestoinfluence

processbehavior

9

Page 10: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Controlequipment

• Inlarge–scaleoperationscontrollogicgetsmorecomplexthanathermostat

• Onewouldneedsomethingbiggerthanathermostattohandleit

• Mostofthetimethisisaprogrammablelogiccontroller(PLC)

10

Page 11: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

What is a PLC?

• AnEmbeddedSystemwithRTOSrunninglogic.

11

Page 12: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

[ifinput1]AND[input2orinput11]->[dosomethinginoutput6]

IftankpressureinPLC1>1800reduceinflowinPLC3

• Itisprogrammedgraphicallymostofthetime• Defineswhatshould/shouldnothappen

− Underwhichconditions− Atwhattime− YesorNoproposition

Controllogic

Page 13: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

1. Copydatafrominputstotemporarystorage2. Runthelogic3. Copyfromtemporarystoragetooutputs

Inputs

Outputs

SensorsActuators

HowPLCWorks

Read Inputs

Logic Program

Update Outputs

Logic Variable Table (VT)

Runtime

Inputs

Outputs

Physical I/O

Read/Write I/O

Inputs from I/O

Set Points

Outputs to I/O

Read/Write VT

Page 14: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

• Usedtocomputeoutputbasedoninputsreceivedfromcontrollogic

JacquesSmuts„ProcessControlforPractitioners“

Controlalgorithm

• PID:proportional,integral,derivative– mostwidelyusedcontrolalgorithmontheplanet

• PIcontrollersaremostoftenused

Page 15: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

ExistingAttacksandDefensesforEmbeddedSystemsApplicabletothePLCs

15

Page 16: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Current attacks against embedded systems

• Authenticationbypass• AttackerfindabackdoorpasswordinthePLC.

• Firmwaremodificationattacks• AttackeruploadnewfirmwaretothePLC

• Configurationmanipulationattacks• Attackermodifythelogic

• ControlFlowattacks• AttackerfindabufferoverfloworRCEinthePLC

• HookingfunctionsforICSmalwares

16

Page 17: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Current defenses for embedded systems

• Attestation• memoryattestation

• Firmwareintegrityverification• Verifytheintegrityoffirmwarebeforeitsbeinguploaded

• Hookdetection• Codehookingdetection

• Detectcodehooking

• Datahookingdetection• Detectdatahooking

17

Page 18: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

• DesignedforembeddeddevicesrunningmodernOS.

• Nohardwaremodifications.

• LimitedCPUoverhead.

• Novirtualization.

Requirement for Applicable Defenses for PLCs

18

Page 19: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

System-level protection for PLCs

• TrivialDefenses:• LogicChecksum• Firmwareintegrityverification

• Non-trivialsoftware-basedHIDSapplicabletoPLCs• Doppelganger(Symbiote Defense):animplementationforsoftwaresymbiotes forembeddeddevices

• AutoscopyJR:Ahostbasedintrusiondetectionwhichisdesignedtodetectkernelrootkitsforembeddedcontrolsystems

19

Page 20: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

How Doppelganger Works

• Scanthefirmwareofthedeviceforlivecoderegionsandinsertsymbiotes randomly.

1 2

TextLive Code Region 1 Live Code Region 2

Symbiote1 (Checksum of

Region 1)

Symbiote2 (Checksum of

Region 2)Other Memory

regions

Symbiote Manager

Breakpoint 1 Breakpoint 2

Firmware

Other Memory regions

20

Page 21: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

How Autoscopy Jr works

• TriestoDetectsfunctionhookingbylearning

• VerifiesthedestinationfunctionaddressandreturnswiththevaluesandaddressesinTLL(TrustedLocationList)

21

Page 22: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

DebugRegisters

• Designedfordebuggingpurpose.

• Functionhookinginterceptthefunctioncallandmanipulatethefunctionargument.

• WeusedebugregistersinARMprocessorstointerceptmemoryaccess(Nofunctioninterception,nofunctionargumentmanipulation)

22

Page 23: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

23

PinControl

Page 24: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

BackgroundonPinControlPinControlsubsystem

• Pinmultiplexing(type)• Pinconfiguration(in/out)

Systemonchip(SoC)SystemonChip

1 2

3

Pinmultiplexing 24

Page 25: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

PinConfiguration

• InputPin• readablebutnotwriteable

• OutputPin• readableand writeable

25

Page 26: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

HowPLCcontrolsI/O

26

Page 27: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

IntroducingPinControlAttack:AMemoryIllusionOperating

System/KernelMap (I/O Memory, +16bytes)

Request for mapping the physical I/O Memory

ReadPin24

Write 0/1 every 5 sec

PLC Runtime

Pin24==Input(bit==0)

Pin22==Output(bit==1)

Write register

Virtual I/O Memory (mapped)

State Register

Read register

0forbit241forbit22

0/1

1

State Register

Physical I/O Memory

Read register

Write register

0forbit241forbit22

0/1

1

map via MMU

LogicBlinkLEDevery5secinPin22if

Pin24isTrue

27

Page 28: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

IntroducingPinControlAttack:AMemoryIllusionOperating

System/KernelMap (I/O Memory, +16bytes)

Request for mapping the physical I/O Memory

ReadPin24

Write 0/1 every 5 sec

PLC Runtime

Write register

Virtual I/O Memory (mapped)

State Register

Read register

0/1

1

State Register

Physical I/O Memory

Read register

Write register 0/1

1

map via MMU

LogicBlinkLEDevery5secinPin22if

Pin24isTrue

Pin22==Input(bit==0)0 for bit 22

0 for bit 22

Write Failure!!

Pin is in Input Mode

28

Page 29: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

ThinkofcopyingfilestoUSBdrive

29

• Similarmappingbetweenphysicalandvirtualaddresses

• IfUSBdriveisremovedduringcopyoperation,OSreportsawarningback

Page 30: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Letslookatit.

Demo1Digital

30

Page 31: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

NobodythoughtaboutthesameissueforPLCs

31

•Shouldn’tthePLCruntimefailorgetterminatedbecauseofI/Ofailure?

– Nope!

• PLCdesignwasalwaysaboutparamountreliabilityofreal-timeexecution,HIGHup-timeandlong-termusefullifeinharshenvironmentalconditions

• MaliciousmanipulationofPLCwerenotpartofdesignconsiderations:-)

Page 32: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Securityconcernsregardingpincontrol

• Nointerruptforpinconfiguration

– HowtheOSknowsaboutthemodificationofpinconfiguration?– Whatifsomebodymodifiesconfigurationofapinatruntime?– Byswitchinginput pinintooutput pin,itispossibletowritearbitraryvalueintoitsphysicaladdress

• NoInterruptforpinmultiplexing

– HowOSknowsaboutmodificationofpinmultiplexing?– Whatifsomebodymultiplexapinatruntime?– Bymultiplexingpinitispossibletoprevent runtimefromwriting valueintooutputpin

32

Page 33: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Problem statement

• Whatifwecreateanattackusingpincontrolthat:• Donotdofunctionhooking• DonotmodifyexecutablecontentsofthePLCruntime.• Donotchangethelogicfile

• Obviouslyweconsiderotherdefensesavailable(e.g.logicchecksumisalsothere)

33

Page 34: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

PinControlAttack

34

Page 35: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

PinControlAttack

• PinControlAttack:• manipulatetheI/Oconfiguration(PinConfigurationAttack)• manipulatetheI/O multiplexing(PinMultiplexingAttack)

• PLCOSwillneverknowsaboutit.

35

Page 36: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Twooptionstoachievethesame

q Firstversion:rootkit– Rootprivilege– KnowledgeofSoC registers– KnowledgeofmappingbetweenI/Opinsandthelogic

q Secondversion:C-code(shellcode)– EqualprivilegeasPLCruntime– KnowledgeofmappingbetweenI/Opinsandthelogic

1

2

– Nofunctionhooking– NomodificationofPLCruntime

executablecontent– Nochangetologicfile

36

Page 37: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

HowPinConfigurationAttackWorks?

1. Put I/O Address into Debug

register

Manipulate Read

2. Intercept Read Operation from I/O

3. Set Pin to Output Mode

4. Write Desired Value to Output

read(I/O, Pin)

Pin Control Attack actions

PLC runtime actions

read() continue....

1. Put I/O Address into Debug

register

Manipulate Write

2. Intercept Write Operation to I/O

3. Set Pin to Input (write-ignore)

write(I/O, Pin)

write() continue...

37

Page 38: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

SimpleLogic

LetstestitwithasimpleFunctionBlockLanguageLogic.

38

Page 39: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

SimpleLogic2

• SecondLogicforarealPLC

39

Page 40: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

40

Page 41: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

41

Page 42: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Letslookatit.

Demo2Digital

42

Page 43: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Letslookatit.

Demo3Digital

43

Page 44: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

APLCruntimeDynamicandStaticAnalysis

• I/OMapping

• LookforBaseAddresses of I/O

44

Page 45: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

I/OAttack:Rootkit

• RootkitneedsrootusertoinstallitscodeasaLoadableKernelModule(LKM).

• vmalloc()allocatesourLKM.ItevadesDoppelganger.

• Donotdoanykindoffunctionhooking,evadesAutoscopy Jr.

• Canchangethelogicregardlessoflogicoperation.

45

Logic Code

Firmware

I/O Pin

Control attack

Other attacks

Page 46: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

I/Oresponsetimefluctuationinrootkitvariant

46

Page 47: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

CPUOverhead

WriteManipulation:~5%

ReadManipulation:~23%

47

Page 48: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

SecondVariantoftheAttack– NoRootkit!

• Noneedtohaverootkit!

• WecandothesamewiththePLCruntimeprivilege.

• Overheadbelow1%.

• WecaneitherremaptheI/OorusealreadymappedI/Oaddress.

• Asshellcode

48

Page 49: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Secondvariant

Inputs

Outputs

Physical I/O Pin

The Malicious Code

Exported Kernel Object File System

device driver

/dev/mem

Logic

PLC Runtime

Read the I/O Output every 4

millisecond

Read the I/O Input

every 4 millitsecond

Starting Time Calculation Loop

Read Manipulate

Write Manipulate

Reconfigure the I/O Pins

49

Page 50: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

SecondVariant 1. Find the Refrence Starting

Time

Manipulate Read

3. Set Pin to Output Mode (write-enable)

4. Write Desired Value to Output

Pin

read(I/O, Pin)

Pin Control Attack actions

PLC runtime actions

1. Find the Refrence Starting

Time

Manipulate Write

3. Set Pin to Input (write-ignore)

write() to I/O

3. Set Pin to Output

(write-enable)

Write desired value

50

Page 51: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

WhataboutAnalogControl?

• Analogsignalsarebasicallyaggregationofdigitalsignals.

• Twowaystodoit:• 1.Ifpartoforentireanalogmemorycangetmultiplexedtodigitalpinsattackercanmultiplexthepinandwritedigitalbitsandbasicallycontrolthevaluesintheanalogmemory

• 2.UsingthetechniquewhichwecanPC+1,wetelltheinterrupthandlertoreturnthecontroltothenextinstructionwithinthePLCruntime,basicallyavoidingwriteoperationoccur

51

Page 52: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

AnalogI/OManipulation

52

Page 53: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Letslookatit.

DemoAnalog

53

Page 54: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

OtherFuturePossibilities!

• Attackingpull-upandpull-downresistorsinI/Ointerfaces

• Whatifwedisablethem?

• RemotelymanipulatetheI/Oviaapowerfulelectromagneticfield!

54

Page 55: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Nevertrustyourinputs!

55

Page 56: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Discussions• For now attacker can:

• Simply change the logic• Modify PLC Runtime executable

• Fixing these attacks are trivial:• Proper Authentication• Proper Logic Checksum• PLC Runtime integrity verification

• Next Step for attackers:• Achieve its goal without actually modifying the Logic or Runtime or

hooking functions

56

Page 57: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

RacetotheBottom

57

Assoonassecurityisintroducedatsomelayerofcomputerornetworkarchitectureabstraction,theattackersaregoingonelayerdown.

InthehackingcommunityitiscalledRace-to-the-Bottom

Page 58: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Conclusions• Need to focus on system level security of control devices In future

more sophisticated techniques come that evade defenses.• Pin Control attack is an example of such attacks.

• Pin Control Attack:• lack of interrupt for I/O configuration registers• Significant consequences on protected PLCs and other control devices such

as IEDs.

• Solution:• It is hard to handle I/O interrupts with existing real-time constraints.• Monitoring I/O Configuration Pins for anomalies.• User/Kernel space separation for I/O memory.

58

Page 59: Do as I Say not as I Do Stealth Modification of ... · •Need to focus on system level security of control devices In future more sophisticated techniques come that evade defenses

Questions?Lookingformore…

AttendourtalkatDigitalBond S4x17,Miami,USA

Everythingthathasabeginninghasanend.TheMatrixRevolutions.

Contact:

[email protected] @bl4ckic3

@m4ji_d

59