Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1247815%22%20slang%3D%22en-US%22%3EUnderstanding%20Hardware-enforced%20Stack%20Protection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1247815%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20aim%20to%20make%20Windows%2010%20one%20of%20the%20most%20secure%20operating%20systems%20for%20our%20customers%20and%20to%20do%20that%20we%20are%20investing%20in%20a%20multitude%20of%20security%20features.%20Our%20philosophy%20is%20to%20build%20features%20that%20mitigate%20broad%20classes%20of%20vulnerabilities%2C%20ideally%20without%20having%20the%20app%20change%20its%20code.%20In%20other%20words%2C%20getting%20an%20updated%20version%20of%20Windows%2010%20should%20make%20the%20customer%20and%20the%20app%20safer%20to%20use.%20This%20comprehensive%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fthreat-protection%2Foverview-of-threat-mitigations-in-windows-10%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMSDN%20document%3C%2FA%3E%20shows%20all%20of%20the%20security%20focused%20technologies%20we%20have%20built%20into%20Windows%20over%20the%20years%20and%20how%20it%20keeps%20our%20customers%20safe.%20Here%20is%20another%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FMSRC-Security-Research%2Fblob%2Fmaster%2Fpresentations%2F2016_08_BlackHatUSA%2FBHUSA16_Weston_Miller_Windows_10_Mitigation_Improvements.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epresentation%3C%2FA%3E%20by%20Matt%20Miller%20and%20David%20Weston%20that%20goes%20deeper%20into%20our%20security%20philosophy%20for%20further%20reading.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20are%20now%20exploring%20security%20features%20with%20deep%20hardware%20integration%20to%20further%20raise%20the%20bar%20against%20attacks.%20By%20integrating%20Windows%20and%20its%20kernel%20deeply%20with%20hardware%2C%20we%20make%20it%20difficult%20and%20expensive%20for%20attackers%20to%20mount%20large%20scale%20attacks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EROP%20(Return%20Oriented%20Programming)%20based%20control%20flow%20attacks%20have%20become%20a%20common%20form%20of%20attack%20based%20on%20our%20own%20and%20the%20external%20research%20community%E2%80%99s%20investigations%20(%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FMSRC-Security-Research%2Fblob%2Fmaster%2Fpresentations%2F2018_02_OffensiveCon%2FThe%2520Evolution%2520of%2520CFI%2520Attacks%2520and%2520Defenses.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEvolution%20of%20CFI%20attacks%3C%2FA%3E%2C%20Joe%20Bialek).%20Hence%2C%20they%20are%20the%20next%20logical%20point%20of%20focus%20for%20proactive%2C%20built-in%20Windows%20security%20mitigation%20technologies.%20In%20this%20post%2C%20we%20will%20describe%20our%20efforts%20to%20harden%20control%20flow%20integrity%20in%20Windows%2010%20through%20%3CSTRONG%3EHardware-enforced%20stack%3C%2FSTRONG%3E%20%3CSTRONG%3Eprotection%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1383867122%22%20id%3D%22toc-hId--1383867122%22%20id%3D%22toc-hId--1383867122%22%20id%3D%22toc-hId--1383867122%22%3EMemory%20safety%20vulnerabilities%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20most%20common%20class%20of%20vulnerability%20found%20in%20systems%20software%20is%20memory%20safety%20vulnerabilities.%20This%20class%20includes%20buffer%20overruns%2C%20dangling%20pointers%2C%20uninitialized%20variables%2C%20and%20others.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20canonical%20example%20of%20a%20stack%20buffer%20overrun%20is%20copying%20data%20from%20one%20buffer%20to%20another%20without%20bound%20checking%20(i.e.%20strcpy).%20If%20an%20attacker%20replaces%20the%20data%20and%20size%20from%20the%20source%20buffer%2C%20the%20destination%20buffer%20and%20other%20important%20components%20of%20the%20stack%20can%20be%20corrupted%20(i.e.%20return%20addresses)%20to%20point%20to%20attacker%20desired%20code.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Buffer%20Overrun.PNG%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178975i96CAC4E278409B28%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Buffer%20Overrun.PNG%22%20alt%3D%22Buffer%20Overrun.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDangling%20pointers%20occur%20when%20memory%20referenced%20by%20a%20pointer%20is%20de-allocated%20but%20a%20pointer%20to%20that%20memory%20still%20exists.%20In%20use-after-free%20exploits%2C%20the%20attacker%20can%20read%2Fwrite%20through%20the%20dangling%20pointer%20that%20now%20points%20to%20memory%20the%20programmer%20did%20not%20intend%20to.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUninitialized%20variables%20exist%20in%20some%20languages%20where%20variables%20can%20be%20declared%20without%20value%2C%20memory%20in%20this%20case%20is%20initialized%20with%20junk%20data.%20If%20an%20attacker%20can%20read%20or%20write%20to%20these%20contents%2C%20this%20will%20also%20lead%20to%20unintended%20program%20behavior.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20are%20popular%20techniques%20attackers%20can%20utilize%20to%20gain%20control%20and%20run%20arbitrary%20native%20code%20on%20target%20machines.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1103645711%22%20id%3D%22toc-hId-1103645711%22%20id%3D%22toc-hId-1103645711%22%20id%3D%22toc-hId-1103645711%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--703808752%22%20id%3D%22toc-hId--703808752%22%20id%3D%22toc-hId--703808752%22%20id%3D%22toc-hId--703808752%22%3EArbitrary%20Code%20Execution%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20frame%20our%20strategy%20for%20mitigating%20arbitrary%20code%20execution%20in%20the%20form%20of%20four%20pillars%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Arbitrary%20Code%20Execution%20Strategy.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178976i6193E38E542382C8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Arbitrary%20Code%20Execution%20Strategy.jpg%22%20alt%3D%22Arbitrary%20Code%20Execution%20Strategy.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECode%20Integrity%20Guard%20(CIG)%20prevents%20arbitrary%20code%20generation%20by%20enforcing%20signature%20requirements%20for%20loading%20binaries.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EArbitrary%20Code%20Guard%20(ACG)%20ensures%20signed%20pages%20are%20immutable%20and%20dynamic%20code%20cannot%20be%20generated%2C%20thus%20guaranteeing%20the%20integrity%20of%20binaries%20loaded.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20introduction%20of%20CIG%2FACG%2C%20attackers%20increasingly%20resort%20to%20control%20flow%20hijacking%20via%20indirect%20calls%20and%20returns%2C%20known%20as%20call%2Fjump%20oriented%20programming%20(COP%2FJOP)%20and%20return%20oriented%20programming%20(ROP).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20shipped%20Control%20Flow%20Guard%20(CFG)%20in%20Windows%2010%20to%20enforce%20integrity%20on%20indirect%20calls%20(forward-edge%20CFI).%20Hardware-enforced%20Stack%20Protection%20will%20enforce%20integrity%20on%20return%20addresses%20on%20the%20stack%20(backward-edge%20CFI)%2C%20via%20Shadow%20Stacks.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1783704081%22%20id%3D%22toc-hId-1783704081%22%20id%3D%22toc-hId-1783704081%22%20id%3D%22toc-hId-1783704081%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--23750382%22%20id%3D%22toc-hId--23750382%22%20id%3D%22toc-hId--23750382%22%20id%3D%22toc-hId--23750382%22%3EThe%20ROP%20problem%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20systems%20software%2C%20if%20an%20attacker%20finds%20a%20memory%20safety%20vulnerability%20in%20code%2C%20the%20return%20address%20can%20be%20hijacked%20to%20target%20an%20attacker%20defined%20address.%20It%20is%20difficult%20from%20here%20to%20directly%20execute%20a%20malicious%20payload%20in%20Windows%20thanks%20to%20existing%20mitigations%20including%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fbuild%2Freference%2Fnxcompat-compatible-with-data-execution-prevention%3Fview%3Dvs-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EData%20Execution%20Prevention%20(DEP)%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fbuild%2Freference%2Fdynamicbase-use-address-space-layout-randomization%3Fview%3Dvs-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAddress%20Space%20Layout%20Randomization%20(ASLR)%3C%2FA%3E%2C%20but%20control%20can%20be%20transferred%20to%20snippets%20of%20code%20(gadgets)%20in%20executable%20memory.%20Attackers%20can%20find%20gadgets%20that%20end%20with%20the%20RET%20instruction%20(or%20other%20branches)%2C%20and%20chain%20multiple%20gadgets%20to%20perform%20a%20malicious%20action%20(turn%20off%20a%20mitigation)%2C%20with%20the%20end%20goal%20of%20running%20arbitrary%20native%20code.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Return%20Oriented%20Programming.PNG%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178977iD35F1A3BB0C30431%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Return%20Oriented%20Programming.PNG%22%20alt%3D%22Return%20Oriented%20Programming.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--34253486%22%20id%3D%22toc-hId--34253486%22%20id%3D%22toc-hId--34253486%22%20id%3D%22toc-hId--34253486%22%3EHardware-enforced%20stack%20protection%20in%20Windows%2010%26nbsp%3B%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EKeep%20in%20mind%2C%20Hardware-enforced%20stack%20protection%20will%20only%20work%20on%20chipsets%20with%20Intel%E2%80%99s%20Control-flow%20Enforcement%20Technology%20(CET)%20instructions.%20Here%20is%20an%20Intel%20%3CA%20href%3D%22https%3A%2F%2Fsoftware.intel.com%2Fsites%2Fdefault%2Ffiles%2Fmanaged%2F4d%2F2a%2Fcontrol-flow-enforcement-technology-preview.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewhitepaper%3C%2FA%3E%20with%20more%20information%20on%20CET.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20post%2C%20we%20will%20describe%20only%20the%20relevant%20parts%20of%20the%20Windows%2010%20implementation.%20This%20technology%20provides%20parity%20with%20program%20call%20stacks%2C%20by%20keeping%20a%20record%20of%20all%20the%20return%20addresses%20via%20a%20Shadow%20Stack.%20On%20every%20CALL%20instruction%2C%20return%20addresses%20are%20pushed%20onto%20both%20the%20call%20stack%20and%20shadow%20stack%2C%20and%20on%20RET%20instructions%2C%20a%20comparison%20is%20made%20to%20ensure%20integrity%20is%20not%20compromised.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20addresses%20do%20not%20match%2C%20the%20processor%20issues%20a%20control%20protection%20(%23CP)%20exception.%20This%20traps%20into%20the%20kernel%20and%20we%20terminate%20the%20process%20to%20guarantee%20security.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Shadow%20Stacks.PNG%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178980i152475220017F30E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Shadow%20Stacks.PNG%22%20alt%3D%22Shadow%20Stacks.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EShadow%20stacks%20store%20only%20return%20addresses%2C%20which%20helps%20minimize%20the%20additional%20memory%20overhead.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EControl-flow%20Enforcement%20Technology%20(CET)%20Shadow%20Stacks%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EShadow%20stack%20compliant%20hardware%20provides%20extensions%20to%20the%20architecture%20by%20adding%20instructions%20to%20manage%20shadow%20stacks%20and%20hardware%20protection%20of%20shadow%20stack%20pages.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHardware%20will%20have%20a%20new%20register%20SSP%2C%20which%20holds%20the%20%3CSTRONG%3ES%3C%2FSTRONG%3Ehadow%20%3CSTRONG%3ES%3C%2FSTRONG%3Etack%20%3CSTRONG%3EP%3C%2FSTRONG%3Eointer%20address.%20The%20hardware%20will%20also%20have%20page%20table%20extensions%20to%20identify%20shadow%20stack%20pages%20and%20protect%20those%20pages%20against%20attacks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENew%20instructions%20are%20added%20for%20management%20of%20shadow%20stack%20pages%2C%20including%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EINCSSP%20%E2%80%93%20increment%20SSP%20(i.e.%20to%20unwind%20shadow%20stack)%3C%2FLI%3E%0A%3CLI%3ERDSSP%20%E2%80%93%20read%20SSP%20into%20general%20purpose%20register%3C%2FLI%3E%0A%3CLI%3ESAVEPREVSSP%2FRSTORSSP%20%E2%80%93%20save%2Frestore%20shadow%20stack%20(i.e.%20thread%20switching)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20full%20hardware%20implementation%20is%20documented%20in%20%3CA%20href%3D%22https%3A%2F%2Fsoftware.intel.com%2Fsites%2Fdefault%2Ffiles%2Fmanaged%2F4d%2F2a%2Fcontrol-flow-enforcement-technology-preview.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIntel%E2%80%99s%20CET%20manual%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-656307988%22%20id%3D%22toc-hId-656307988%22%20id%3D%22toc-hId-656307988%22%20id%3D%22toc-hId-656307988%22%3ECompiling%20for%20%3CSPAN%3EHardware-enforced%20Stack%20Protection%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20order%20to%20receive%20Hardware-enforced%20stack%20protection%20on%20your%20application%2C%20there%20is%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fbuild%2Freference%2Fcetcompat%3Fview%3Dvs-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enew%20linker%20flag%3C%2FA%3E%20which%20sets%20a%20bit%20in%20the%20PE%20header%20to%20request%20protection%20from%20the%20kernel%20for%20the%20executable.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20application%20sets%20this%20bit%20and%20is%20running%20on%20a%20supported%20Windows%20build%20and%20shadow%20stack-compliant%20hardware%2C%20the%20Kernel%20will%20maintain%20shadow%20stacks%20throughout%20the%20runtime%20of%20the%20program.%20If%20your%20Windows%20version%20or%20the%20hardware%20does%20not%20support%20shadow%20stacks%2C%20then%20the%20PE%20bit%20is%20ignored.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20making%20this%20an%20opt-in%20feature%20of%20Windows%2C%20we%20are%20allowing%20developers%20to%20first%20validate%20and%20test%20their%20app%20with%20hardware-enforced%20stack%20protection%2C%20before%20releasing%20their%20app.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHardware-enforced%20Stack%20Protection%20feature%20is%20under%20development%20and%20an%20early%20preview%20is%20available%20in%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-insider%2Fat-home%2FWhats-new-at-wip-home%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%2010%20Insider%20previews%20builds%20(fast%20ring)%3C%2FA%3E.%20If%20you%20have%20Intel%20CET%20capable%20hardware%2C%20you%20can%20enable%20the%20above%20linker%20flag%20on%20your%20application%20to%20test%20with%20the%20latest%20Windows%2010%20insider%20builds.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-645804884%22%20id%3D%22toc-hId-645804884%22%20id%3D%22toc-hId-645804884%22%20id%3D%22toc-hId-645804884%22%3EConclusion%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHardware-enforced%20Stack%20Protection%20offers%20robust%20protection%20against%20ROP%20exploits%20since%20it%20maintains%20a%20record%20of%20the%20intended%20execution%20flow%20of%20a%20program.%20To%20ensure%20smooth%20ecosystem%20adoption%20and%20application%20compatibility%2C%20Windows%20will%20offer%20this%20protection%20as%20an%20opt-in%20model%2C%20so%20developers%20can%20receive%20this%20protection%2C%20at%20your%20own%20pace.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20will%20provide%20ongoing%20guidance%20on%20how%20to%20re-build%20your%20application%20to%20be%20shadow%20stacks%20compliant.%20In%20our%20next%20post%2C%20we%20will%20dig%20deeper%20into%20best%20practices%2C%20as%20well%20as%20provide%20technical%20documentation.%20This%20protection%20will%20be%20a%20major%20step%20forward%20in%20our%20continuous%20efforts%20to%20make%20Windows%2010%20one%20of%20the%20most%20secure%20operating%20system%20for%20our%20customers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EKernel%20protection%20team%20-%20Jin%20Lin%2C%20Jason%20Lin%2C%20Niraj%20Majmudar%20and%20Greg%20Colombo%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1247815%22%20slang%3D%22en-US%22%3E%3CP%3EROP%20(Return%20Oriented%20Programming)%20based%20control%20flow%20attacks%20have%20become%20a%20common%20form%20of%20attack.%20In%20this%20post%2C%20we%20will%20describe%20our%20efforts%20to%20harden%20control%20flow%20integrity%20in%20Windows%2010%20through%20Hardware-enforced%20stack%20protection.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1252128%22%20slang%3D%22en-US%22%3ERe%3A%20Understanding%20Hardware-enforced%20Stack%20Protection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1252128%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20article%20.%20This%20type%20feature%20is%26nbsp%3B%20really%26nbsp%3B%20needed%20for%20all%20consumers%20.%3C%2FP%3E%3CP%3EBut%20i%20want%20to%20know%20which%20processors%26nbsp%3B%20are%26nbsp%3B%20supported%20to%20this%20feature%20.%20Any%20restrictions.%3C%2FP%3E%3CP%3ECurrently%20i%20am%20intel%20i5%207700u%20kabylake%20processor%20with%20micrsocode%20B4%20with%20intel%20TPM%202.0%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1258440%22%20slang%3D%22en-US%22%3ERe%3A%20Understanding%20Hardware-enforced%20Stack%20Protection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1258440%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F322694%22%20target%3D%22_blank%22%3E%40RAJUMATHEMATICSMSC%3C%2FA%3E-%20you%20can%20use%20the%20Intel%20ARK%20to%20search%20by%20feature%20set%2C%20and%20find%20out%20anything%20you%20need%20to%20know%20about%20Intel%20processors.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fark.intel.com%2Fcontent%2Fwww%2Fus%2Fen%2Fark.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fark.intel.com%2Fcontent%2Fwww%2Fus%2Fen%2Fark.html%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

We aim to make Windows 10 one of the most secure operating systems for our customers and to do that we are investing in a multitude of security features. Our philosophy is to build features that mitigate broad classes of vulnerabilities, ideally without having the app change its code. In other words, getting an updated version of Windows 10 should make the customer and the app safer to use. This comprehensive MSDN document shows all of the security focused technologies we have built into Windows over the years and how it keeps our customers safe. Here is another presentation by Matt Miller and David Weston that goes deeper into our security philosophy for further reading.

 

We are now exploring security features with deep hardware integration to further raise the bar against attacks. By integrating Windows and its kernel deeply with hardware, we make it difficult and expensive for attackers to mount large scale attacks.

 

ROP (Return Oriented Programming) based control flow attacks have become a common form of attack based on our own and the external research community’s investigations (Evolution of CFI attacks, Joe Bialek). Hence, they are the next logical point of focus for proactive, built-in Windows security mitigation technologies. In this post, we will describe our efforts to harden control flow integrity in Windows 10 through Hardware-enforced stack protection.

 

Memory safety vulnerabilities

 

The most common class of vulnerability found in systems software is memory safety vulnerabilities. This class includes buffer overruns, dangling pointers, uninitialized variables, and others.

 

A canonical example of a stack buffer overrun is copying data from one buffer to another without bound checking (i.e. strcpy). If an attacker replaces the data and size from the source buffer, the destination buffer and other important components of the stack can be corrupted (i.e. return addresses) to point to attacker desired code.

 

Buffer Overrun.PNG

 

Dangling pointers occur when memory referenced by a pointer is de-allocated but a pointer to that memory still exists. In use-after-free exploits, the attacker can read/write through the dangling pointer that now points to memory the programmer did not intend to.

 

Uninitialized variables exist in some languages where variables can be declared without value, memory in this case is initialized with junk data. If an attacker can read or write to these contents, this will also lead to unintended program behavior.

 

These are popular techniques attackers can utilize to gain control and run arbitrary native code on target machines.

 

Arbitrary Code Execution

 

We frame our strategy for mitigating arbitrary code execution in the form of four pillars:

 

Arbitrary Code Execution Strategy.jpg

 

Code Integrity Guard (CIG) prevents arbitrary code generation by enforcing signature requirements for loading binaries.

 

Arbitrary Code Guard (ACG) ensures signed pages are immutable and dynamic code cannot be generated, thus guaranteeing the integrity of binaries loaded.

 

With the introduction of CIG/ACG, attackers increasingly resort to control flow hijacking via indirect calls and returns, known as call/jump oriented programming (COP/JOP) and return oriented programming (ROP).

 

We shipped Control Flow Guard (CFG) in Windows 10 to enforce integrity on indirect calls (forward-edge CFI). Hardware-enforced Stack Protection will enforce integrity on return addresses on the stack (backward-edge CFI), via Shadow Stacks.

 

The ROP problem

 

In systems software, if an attacker finds a memory safety vulnerability in code, the return address can be hijacked to target an attacker defined address. It is difficult from here to directly execute a malicious payload in Windows thanks to existing mitigations including Data Execution Prevention (DEP) and Address Space Layout Randomization (ASLR), but control can be transferred to snippets of code (gadgets) in executable memory. Attackers can find gadgets that end with the RET instruction (or other branches), and chain multiple gadgets to perform a malicious action (turn off a mitigation), with the end goal of running arbitrary native code.

 

Return Oriented Programming.PNG

 

Hardware-enforced stack protection in Windows 10 

 

Keep in mind, Hardware-enforced stack protection will only work on chipsets with Intel’s Control-flow Enforcement Technology (CET) instructions. Here is an Intel whitepaper with more information on CET.

 

In this post, we will describe only the relevant parts of the Windows 10 implementation. This technology provides parity with program call stacks, by keeping a record of all the return addresses via a Shadow Stack. On every CALL instruction, return addresses are pushed onto both the call stack and shadow stack, and on RET instructions, a comparison is made to ensure integrity is not compromised.

 

If the addresses do not match, the processor issues a control protection (#CP) exception. This traps into the kernel and we terminate the process to guarantee security.

 

Shadow Stacks.PNG

 

Shadow stacks store only return addresses, which helps minimize the additional memory overhead.

 

Control-flow Enforcement Technology (CET) Shadow Stacks

 

Shadow stack compliant hardware provides extensions to the architecture by adding instructions to manage shadow stacks and hardware protection of shadow stack pages.

 

Hardware will have a new register SSP, which holds the Shadow Stack Pointer address. The hardware will also have page table extensions to identify shadow stack pages and protect those pages against attacks.

 

New instructions are added for management of shadow stack pages, including:

  • INCSSP – increment SSP (i.e. to unwind shadow stack)
  • RDSSP – read SSP into general purpose register
  • SAVEPREVSSP/RSTORSSP – save/restore shadow stack (i.e. thread switching)

The full hardware implementation is documented in Intel’s CET manual.

 

Compiling for Hardware-enforced Stack Protection

 

In order to receive Hardware-enforced stack protection on your application, there is a new linker flag which sets a bit in the PE header to request protection from the kernel for the executable.

 

If the application sets this bit and is running on a supported Windows build and shadow stack-compliant hardware, the Kernel will maintain shadow stacks throughout the runtime of the program. If your Windows version or the hardware does not support shadow stacks, then the PE bit is ignored.

 

By making this an opt-in feature of Windows, we are allowing developers to first validate and test their app with hardware-enforced stack protection, before releasing their app.  

 

Hardware-enforced Stack Protection feature is under development and an early preview is available in Windows 10 Insider previews builds (fast ring). If you have Intel CET capable hardware, you can enable the above linker flag on your application to test with the latest Windows 10 insider builds.

 

Conclusion

 

Hardware-enforced Stack Protection offers robust protection against ROP exploits since it maintains a record of the intended execution flow of a program. To ensure smooth ecosystem adoption and application compatibility, Windows will offer this protection as an opt-in model, so developers can receive this protection, at your own pace.

 

We will provide ongoing guidance on how to re-build your application to be shadow stacks compliant. In our next post, we will dig deeper into best practices, as well as provide technical documentation. This protection will be a major step forward in our continuous efforts to make Windows 10 one of the most secure operating system for our customers.

 

Kernel protection team - Jin Lin, Jason Lin, Niraj Majmudar and Greg Colombo

 

2 Comments
Contributor

Thanks for the article . This type feature is  really  needed for all consumers .

But i want to know which processors  are  supported to this feature . Any restrictions.

Currently i am intel i5 7700u kabylake processor with micrsocode B4 with intel TPM 2.0 .

Occasional Visitor

@RAJUMATHEMATICSMSC- you can use the Intel ARK to search by feature set, and find out anything you need to know about Intel processors.

 

https://ark.intel.com/content/www/us/en/ark.html