%3CLINGO-SUB%20id%3D%22lingo-sub-1548973%22%20slang%3D%22en-US%22%3EAzure%20Sphere%2020.07%20Security%20Enhancements%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1548973%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20release%20of%2020.07%20brought%20along%20a%20range%20of%20security%20enhancements%20and%20changes%20to%20Azure%20Sphere.%20As%20head%20of%20the%20Operating%20System%20Platform%20(OSP)%20Security%20team%2C%20I%20want%20to%20provide%20more%20insights%20into%20the%20efforts%20to%20keep%20Azure%20Sphere%20secure%20as%20a%20platform%20while%20being%20as%20transparent%20as%20possible%20about%20all%20the%20improvements%20made%20since%20our%2020.04%20release.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20OSP%20Security%20team%20I%20run%20for%20Azure%20Sphere%20worked%20with%20a%20diverse%20group%20of%20people%20and%20companies%20to%20have%20three%20separate%20red%20team%20events%20happen%20on%20the%20platform%20over%20the%20last%20few%20months%3B%20an%20internal%20Microsoft%20team%2C%20Trail%20of%20Bits%2C%20and%20the%20currently%20active%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fmsrc%2Fazure-security-lab%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sphere%20Security%20Research%20Challenge%3C%2FA%3E%20(ASSRC).%20These%20efforts%20are%20on%20top%20of%20the%20continued%20work%20done%20by%20the%20OSP%20team%20over%20the%20last%20three%20months%20to%20harden%20and%20further%20the%20security%20of%20the%20platform.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETrail%20of%20Bits%20performed%20a%20private%20red%20team%20exercise%20on%20the%20system%20and%20identified%20a%20number%20of%20risks%20that%20have%20been%20fixed%20for%2020.07%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20%2Fproc%20file%20system%20on%20Linux%20is%20mounted%20rw%20giving%20the%20ability%20to%20write%20to%20%2Fproc%2Fself%2Fmem%20allowing%20unsigned%20code%20execution%2C%20%2Fproc%2Fself%2Fmem%20is%20now%20read-only%3C%2FLI%3E%0A%3CLI%3EThe%20internal%20GetRandom()%20function%20failed%20to%20properly%20fill%20in%20buffers%20that%20have%20a%20length%20that%20is%20not%20a%20multiple%20of%204%2C%20all%20current%20usage%20is%20a%20multiple%20of%204%20so%20no%20risk%20and%20code%20was%20changed%20to%20avoid%20future%20impacts%3C%2FLI%3E%0A%3CLI%3EThe%20Sysctl%20Linux%20kernel%20configuration%20flags%20can%20be%20hardened%2C%20following%20values%20enabled%3CUL%3E%0A%3CLI%3E%26nbsp%3Bkernel.kptr_restrict%20%3D%201%20-%20limit%20Linux%20kernel%20pointer%20leakage%3C%2FLI%3E%0A%3CLI%3E%26nbsp%3Bkernel.dmesg_restrict%20%3D%201%20-%20prevent%20access%20to%20dmesg%20to%20unprivleged%20processes%3C%2FLI%3E%0A%3CLI%3Efs.protected_hardlinks%20%3D%201%20-%20users%20cannot%20create%20hardlinks%20unless%20they%20own%20the%20source%20file%3C%2FLI%3E%0A%3CLI%3Efs.protected_symlinks%20%3D%201%20-%20symlinks%20are%20only%20followed%20when%20not%20in%20a%20world-writable%20directory%2C%20the%20owner%20of%20the%20symlink%20and%20follower%20match%2C%20or%20the%20directory%20owner%20and%20fsymlink%20owner%20match%3C%2FLI%3E%0A%3CLI%3Efs.protected_fifos%20%3D%202%20-%20limit%20FIFO%20creation%20options%20when%20dealing%20with%20world%20writable%20directories%3C%2FLI%3E%0A%3CLI%3Efs.protected_regular%20%3D%202%20-%20limit%20regular%20file%20creation%20options%20when%20dealing%20with%20world%20writable%20directories%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EThe%20internal%20security%20library%20for%20setting%20process%20information%20used%20to%20return%20success%20even%20if%20failed%20to%20set%20a%20process'%20capabilities%3C%2FLI%3E%0A%3CLI%3EDNS%20name%20expansion%20leaked%20stack%20memory%3C%2FLI%3E%0A%3CLI%3ENull%20pointer%20dereferences%20in%20DMA%20memory%20for%20mtk3620%20in%20the%20Linux%20kernel%3C%2FLI%3E%0A%3CLI%3EBetter%20filtering%20of%20the%20content-type%20for%20GatewayD%20to%20limit%20cross-site%20scripting%20abuse%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAlthough%20the%20ASSRC%20is%20still%20on-going%20it%20has%20provided%20a%20range%20of%20great%20findings%20by%20the%20participants%2C%20some%20of%20which%20overlapped%20ToB's%20findings%20like%20a%20writable%20%2Fproc%2Fself%2Fmem.%20The%20Linux%20kernel%20related%20issues%20identified%20by%20ToB%20were%20not%20fixed%20in%2020.05%20or%2020.06%20due%20to%20the%20massive%20Linux%20kernel%20uprgade%20from%204.9%20to%205.4%2C%20this%20oversight%20will%20be%20handled%20better%20in%20the%20future.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECisco%20Talos%20reported%20the%20first%202%20findings%20that%20are%20fixed%20in%2020.07%2C%20ptrace%20used%20to%20bypass%20the%20unsigned%20code%20execution%20protections%20and%20the%20Linux%20kernel%20message%20ring%20buffer%20being%20user%20accessible%20allowing%20for%20information%20leakage.%20Along%20with%20reporting%20the%20first%20two%20findings%2C%20Cisco%20Talos%20also%20reported%20the%20%2Fproc%2Fself%2Fmem%20finding%20and%20found%20a%20double%20free%20in%20the%20azspio%20Linux%20kernel%20driver%20that%20have%20been%20fixed.%20Cisco%20has%20a%20%3CA%20href%3D%22https%3A%2F%2Fblog.talosintelligence.com%2F2020%2F07%2Fvuln-spotlight-azure-sphere-july-2020.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eblog%20post%3C%2FA%3E%20up%20detailing%20their%20efforts%20so%20far%20for%20the%20ASSRC.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20an%20excellent%20example%20of%20findings%20from%20the%20ASSRC%20effort%2C%20I%20would%20like%20to%20describe%20a%20specific%20attack%20chain%20that%20McAfee%20Advanced%20Threat%20Research%20found%20for%20the%20device%20that%20has%20been%20fixed%20for%2020.07.%20This%20attack%20chain%20did%20require%20physical%20access%20to%20a%20device%20and%20could%20not%20be%20done%20remotely%20due%20to%20the%20steps%20involved.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EWe%20have%20multiple%20environments%20that%20devices%20can%20be%20part%20of%2C%20two%20of%20them%20are%20pre-production%20and%20production.%20McAfee%20ATR%20was%20able%20to%20claim%20a%20device%20to%20both%20preproduction%20and%20production%20across%20separate%20tenants.%20Due%20to%20an%20oversight%20in%20signature%20handling%20for%20device%20capability%20images%20on%20the%20cloud%2C%20an%20attacker%20that%20claimed%20a%20device%20they%20did%20not%20own%20to%20pre-production%20was%20allowed%20to%20request%20a%20capability%20image%20for%20the%20device%20that%20was%20production%20signed.%20This%20allowed%20obtaining%20a%20capability%20image%20for%20a%20device%20and%20gaining%20access%20to%20a%20locked%20down%20device%2C%20this%20was%20corrected%20immediately.%3C%2FLI%3E%0A%3CLI%3EWith%20the%20ability%20to%20get%20a%20capability%20image%20for%20a%20device%2C%20McAfee%20ATR%20could%20unlock%20a%20locked%20down%20device%20and%20also%20obtain%20the%20development%20capability%20allowing%20them%20to%20upload%20their%20own%20package%20to%20the%20device.%20An%20application%20package%20is%20a%20signed%20ASXIPFS%20image%2C%20our%20file%20system%20that%20is%20a%20variation%20of%20CramFS%20with%20the%20ability%20to%20execute%20from%20flash.%20The%20original%20file%20system%20code%20allowed%20for%20special%20inode%20filesystem%20entries%20which%20McAfee%20ATR%20used%20to%20create%20a%20special%20inode%20pointing%20to%20the%20MTD%20flash%20giving%20them%20read-only%20access%20to%20the%20on-device%20flash.%2020.07%20removes%20the%20ability%20to%20create%20any%20special%20inodes%20in%20the%20ASXIPFS%20image.%26nbsp%3BCisco%20also%20found%20and%20reported%20this%20vulnerability.%3C%2FLI%3E%0A%3CLI%3EAlthough%20the%20user%20controlled%20special%20inode%20pointing%20to%20flash%20is%20read-only%20due%20to%20how%20the%20file%20system%20image%20is%20mounted%2C%20McAfee%20ATR%20found%20a%200-day%20in%20the%20Linux%20kernel%20for%20the%20MTD_WRITE%20ioctl.%20The%20ioctl%20function%20failed%20to%20check%20permissions%20before%20executing%20the%20ioctl%20call%20allowing%20flipping%20bits%20in%20flash%20from%201%20to%200%20allowing%20McAfee%20ATR%20to%20use%20this%20vulnerability%20to%20rewrite%20the%20uid_map%20file%20for%20the%20device.%20This%20is%20patched%20on%20our%20Linux%20kernel%20for%2020.07%20and%20publicly%20fixed%20with%20%3CA%20href%3D%22https%3A%2F%2Flkml.org%2Flkml%2F2020%2F7%2F16%2F430%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flkml.org%2Flkml%2F2020%2F7%2F16%2F430%3C%2FA%3E.%26nbsp%3BCisco%20also%20found%20and%20reported%20this%20vulnerability.%3C%2FLI%3E%0A%3CLI%3EWith%20the%20ability%20to%20modify%20flash%2C%20McAfee%20ATR%20rewrote%20the%20uid_map%20file%20that%20maps%20user%20IDs%20to%20applications%20to%20have%20an%20application%20with%20a%20maximum%20user%20ID%20where%20all%20bits%20in%20the%20user%20ID%20are%20set.%20The%20maximum%20ID%20resulted%20in%20the%20setresuid%20and%20setresgid%20function%20calls%20being%20passed%20-1.%20A%20-1%20value%20to%20these%20functions%20is%20a%20special%20flag%20to%20indicate%20that%20the%20user%20id%20and%20group%20id%20should%20not%20be%20modified%20resulting%20in%20an%20application%20being%20ran%20as%20the%20sys%20user.%20The%20uid%20map%20parsing%20code%20no%20longer%20allows%20for%20a%20maxium%20user%20ID%20where%20all%20bits%20are%20set.%3C%2FLI%3E%0A%3CLI%3EUnder%20normal%20operation%2C%20a%20system%20package%20can%20not%20be%20uninstalled%2C%20however%20an%20application%20running%20as%20sys%20is%20allowed%20to%20modify%20and%20change%20symlinks%20in%20various%20directories%20resulting%20in%20the%20ability%20to%20abuse%20symlink%20confusion%20on%20packages%20and%20force%20the%20azcore%20package%20to%20be%20uninstalled%20when%20the%20uninstaller%20thinks%20it%20is%20uninstalling%20another%20application.%20From%20there%20a%20user%20package%20can%20be%20installed%20in%20it's%20place.%20Symlinks%20are%20no%20longer%20allowed%20in%20user%20application%20packages%20as%20of%2020.07.%3C%2FLI%3E%0A%3CLI%3EThe%20user%20application%20that%20replaces%20azcore%20does%20have%20the%20proper%20uid%20and%20gid%20set%20when%20executed%20however%20because%20the%20Linux%20kernel%20executes%20it%20the%20capability%20bits%20were%20never%20cleared%20out.%20The%20user%20replaced%20azcore%20is%20then%20able%20to%20call%20setuid(0)%20and%20become%20root%20on%20the%20device.%20This%20will%20be%20fixed%20in%2020.08.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EMcAfee%20ATR%20did%20a%20fantastic%20job%20putting%20together%20this%20attack%20chain%20and%20finding%20a%200-day%20in%20the%20core%20Linux%20kernel%20itself%20to%20make%20it%20work.%20The%20attack%20chain%20exposed%20a%20weakness%20in%20the%20cloud%20and%20multiple%20weakenesses%20on%20the%20device%20including%20a%20previously%20unknown%20Linux%20kernel%20vulnerability.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20the%20above%20changes%20were%20done%20as%20a%20result%20of%20external%20red%20team%20findings%2C%20the%20Operating%20System%20Platform%20team%20continued%20improving%20the%20security%20of%20Azure%20Sphere.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20effort%20we've%20been%20working%20on%20is%20minimizing%20the%20ability%20to%20use%20ptrace%20unless%20in%20development%20mode.%20PTrace%20is%20needed%20by%20gdb%20to%20properly%20provide%20debug%20information%20however%20normal%20customer%20applications%20do%20not%20have%20a%20need%20for%20it.%20Having%20ptrace%20be%20available%20to%20customer%20applications%20allows%20an%20attacker%20to%20ptrace%20the%20process%20being%20attacked%20and%20inject%20unsigned%20code%20into%20memory%20for%20execution.%2020.07%20brings%20along%20a%20Linux%20kernel%20change%20where%20ptrace%20is%20no%20longer%20possible%20unless%20in%20development%20which%20also%20brings%20along%20a%20few%20extra%20enhancements%20as%20a%20side%20effect%2C%20the%20largest%20being%20that%20%2Fproc%20no%20longer%20shows%20any%20other%20process%20pid%20and%20is%20further%20restricted%20of%20what%20a%20process%20can%20know%20about%20itself.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20security%20enhancement%20is%20moving%20to%20wolfSSL%204.4.0%20bringing%20along%20additional%20side%20channel%20attack%20hardening.%20Along%20with%20the%20wolfSSL%20upgrade%20is%20work%20to%20begin%20exposing%20access%20to%20supported%20wolfSSL%20functionality%2C%20the%20first%20set%20of%20functions%20allowing%20customers%20to%20directly%20call%20wolfSSL%20for%20establishing%20TLS%20client%20connections.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20have%20added%20more%20fuzzing%20across%205%20different%20components%20and%20additional%20static%20code%20analysis%20tools%20including%20extra%20static%20analysis%20tools%20on%20every%20pull%20request%20into%20our%20repositories.%20If%20the%20static%20analysis%20fails%20then%20the%20PR%20can%20not%20be%20completed%2C%20this%20further%20strengthens%20the%20system%20by%20making%20it%20more%20difficult%20to%20check%20in%20easy%20to%20abuse%20coding%20flaws.%20As%20we%20expand%20to%20add%20features%20and%20functionality%20more%20fuzzers%20are%20built%20for%20parts%20of%20the%20system%20being%20updated.%20The%20addition%20of%20the%20new%20static%20analysis%20tool%20detected%20an%20off%20by%20one%20calculation%20in%20DHCP%20message%20handling%20that%20allowed%20reading%20an%20extra%20byte%20of%20data%20past%20the%20end%20of%20the%20buffer%2C%20this%20was%20corrected%20in%2020.07.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20have%20noticed%20that%20our%20last%20couple%20quality%20releases%20did%20not%20have%20a%20Linux%20kernel%20patch%20bump%2C%20this%20time%20was%20used%20to%20allow%20the%20Linux%20kernel%20team%20to%20upgrade%20the%20Linux%20kernel%20from%204.9%20to%205.4.44.%20By%20doing%20so%20we%20capture%20Linux%20kernel%20security%20enhancements%20done%20between%20the%20versions%20along%20with%20keeping%20up-to-date%20on%20the%20latest%20changes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EString%20manipulation%20functions%20are%20a%20very%20common%20way%20for%20leaking%20the%20stack%20cookie%20along%20with%20being%20able%20to%20write%20it%20when%20string%20buffers%20are%20not%20properly%20null%20terminated.%20GLibC%20helps%20limit%20string%20buffer%20attacks%20by%20forcing%20the%20first%20byte%20of%20the%20stack%20cookie%20in%20memory%20to%20be%200%20however%20we%20use%20musl%20on%20the%20device%20for%20libc.%20Musl%20initializes%20all%20bytes%20in%20the%20stack%20cookie%20instead%20of%20leaving%20the%20first%20byte%20in%20memory%200%20allowing%20for%20the%20potential%20of%20stack%20cookie%20leaks%20and%20abuses.%20Our%20version%20of%20musl%20in%2020.07%20sets%20the%20first%20byte%20to%200%20and%20the%20patch%20was%20provided%20to%20the%20maintainer%20incase%20they%20wish%20to%20add%20this%20security%20measure%20to%20musl.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20top%20of%20our%20own%20changes%2C%20MediaTek%20provided%20a%20new%20version%20of%20the%20firmware%20for%20their%20WiFi%20subsystem%20of%20their%20MT3620%20that%20is%20now%20being%20used%20on%20the%20platform%20to%20deal%20with%20a%20range%20of%20issues.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20a%20wide%20range%20of%20security%20improvements%20have%20been%20made%20to%20the%20platform%20as%20we%20continue%20to%20strive%20to%20be%20the%20best%20in%20the%20field.%20We%20will%20continue%20to%20be%20transparent%20about%20our%20efforts%20and%20are%20devoted%20to%20being%20the%20most%20secure%20platform%20for%20IoT.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJewell%20Seay%3CBR%20%2F%3EAzure%20Sphere%20OSP%20Security%20Team%20Lead%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1548973%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22iot-overview.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%2F209364iABE93CF4D457791C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22iot-overview.jpg%22%20alt%3D%22iot-overview.jpg%22%20%2F%3E%3C%2FSPAN%3EThe%20release%20of%2020.07%20brought%20along%20a%20range%20of%20security%20enhancements%20and%20changes%20to%20Azure%20Sphere.%20As%20head%20of%20the%20Operating%20System%20Platform%20(OSP)%20Security%20team%2C%20I%20want%20to%20provide%20more%20insights%20into%20the%20efforts%20to%20keep%20Azure%20Sphere%20secure%20as%20a%20platform%20while%20being%20as%20transparent%20as%20possible%20about%20all%20the%20improvements%20made%20since%20our%2020.04%20release.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1548973%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Sphere%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

The release of 20.07 brought along a range of security enhancements and changes to Azure Sphere. As head of the Operating System Platform (OSP) Security team, I want to provide more insights into the efforts to keep Azure Sphere secure as a platform while being as transparent as possible about all the improvements made since our 20.04 release.

 

The OSP Security team I run for Azure Sphere worked with a diverse group of people and companies to have three separate red team events happen on the platform over the last few months; an internal Microsoft team, Trail of Bits, and the currently active Azure Sphere Security Research Challenge (ASSRC). These efforts are on top of the continued work done by the OSP team over the last three months to harden and further the security of the platform.

 

Trail of Bits performed a private red team exercise on the system and identified a number of risks that have been fixed for 20.07:

  • The /proc file system on Linux is mounted rw giving the ability to write to /proc/self/mem allowing unsigned code execution, /proc/self/mem is now read-only
  • The internal GetRandom() function failed to properly fill in buffers that have a length that is not a multiple of 4, all current usage is a multiple of 4 so no risk and code was changed to avoid future impacts
  • The Sysctl Linux kernel configuration flags can be hardened, following values enabled
    •  kernel.kptr_restrict = 1 - limit Linux kernel pointer leakage
    •  kernel.dmesg_restrict = 1 - prevent access to dmesg to unprivleged processes
    • fs.protected_hardlinks = 1 - users cannot create hardlinks unless they own the source file
    • fs.protected_symlinks = 1 - symlinks are only followed when not in a world-writable directory, the owner of the symlink and follower match, or the directory owner and fsymlink owner match
    • fs.protected_fifos = 2 - limit FIFO creation options when dealing with world writable directories
    • fs.protected_regular = 2 - limit regular file creation options when dealing with world writable directories
  • The internal security library for setting process information used to return success even if failed to set a process' capabilities
  • DNS name expansion leaked stack memory
  • Null pointer dereferences in DMA memory for mtk3620 in the Linux kernel
  • Better filtering of the content-type for GatewayD to limit cross-site scripting abuse

Although the ASSRC is still on-going it has provided a range of great findings by the participants, some of which overlapped ToB's findings like a writable /proc/self/mem. The Linux kernel related issues identified by ToB were not fixed in 20.05 or 20.06 due to the massive Linux kernel uprgade from 4.9 to 5.4, this oversight will be handled better in the future.

 

Cisco Talos reported the first 2 findings that are fixed in 20.07, ptrace used to bypass the unsigned code execution protections and the Linux kernel message ring buffer being user accessible allowing for information leakage. Along with reporting the first two findings, Cisco Talos also reported the /proc/self/mem finding and found a double free in the azspio Linux kernel driver that have been fixed. Cisco has a blog post up detailing their efforts so far for the ASSRC.

 

As an excellent example of findings from the ASSRC effort, I would like to describe a specific attack chain that McAfee Advanced Threat Research found for the device that has been fixed for 20.07. This attack chain did require physical access to a device and could not be done remotely due to the steps involved.

  1. We have multiple environments that devices can be part of, two of them are pre-production and production. McAfee ATR was able to claim a device to both preproduction and production across separate tenants. Due to an oversight in signature handling for device capability images on the cloud, an attacker that claimed a device they did not own to pre-production was allowed to request a capability image for the device that was production signed. This allowed obtaining a capability image for a device and gaining access to a locked down device, this was corrected immediately.
  2. With the ability to get a capability image for a device, McAfee ATR could unlock a locked down device and also obtain the development capability allowing them to upload their own package to the device. An application package is a signed ASXIPFS image, our file system that is a variation of CramFS with the ability to execute from flash. The original file system code allowed for special inode filesystem entries which McAfee ATR used to create a special inode pointing to the MTD flash giving them read-only access to the on-device flash. 20.07 removes the ability to create any special inodes in the ASXIPFS image. Cisco also found and reported this vulnerability.
  3. Although the user controlled special inode pointing to flash is read-only due to how the file system image is mounted, McAfee ATR found a 0-day in the Linux kernel for the MTD_WRITE ioctl. The ioctl function failed to check permissions before executing the ioctl call allowing flipping bits in flash from 1 to 0 allowing McAfee ATR to use this vulnerability to rewrite the uid_map file for the device. This is patched on our Linux kernel for 20.07 and publicly fixed with https://lkml.org/lkml/2020/7/16/430. Cisco also found and reported this vulnerability.
  4. With the ability to modify flash, McAfee ATR rewrote the uid_map file that maps user IDs to applications to have an application with a maximum user ID where all bits in the user ID are set. The maximum ID resulted in the setresuid and setresgid function calls being passed -1. A -1 value to these functions is a special flag to indicate that the user id and group id should not be modified resulting in an application being ran as the sys user. The uid map parsing code no longer allows for a maxium user ID where all bits are set.
  5. Under normal operation, a system package can not be uninstalled, however an application running as sys is allowed to modify and change symlinks in various directories resulting in the ability to abuse symlink confusion on packages and force the azcore package to be uninstalled when the uninstaller thinks it is uninstalling another application. From there a user package can be installed in it's place. Symlinks are no longer allowed in user application packages as of 20.07.
  6. The user application that replaces azcore does have the proper uid and gid set when executed however because the Linux kernel executes it the capability bits were never cleared out. The user replaced azcore is then able to call setuid(0) and become root on the device. This will be fixed in 20.08.

McAfee ATR did a fantastic job putting together this attack chain and finding a 0-day in the core Linux kernel itself to make it work. The attack chain exposed a weakness in the cloud and multiple weakenesses on the device including a previously unknown Linux kernel vulnerability.

 

While the above changes were done as a result of external red team findings, the Operating System Platform team continued improving the security of Azure Sphere.

 

One effort we've been working on is minimizing the ability to use ptrace unless in development mode. PTrace is needed by gdb to properly provide debug information however normal customer applications do not have a need for it. Having ptrace be available to customer applications allows an attacker to ptrace the process being attacked and inject unsigned code into memory for execution. 20.07 brings along a Linux kernel change where ptrace is no longer possible unless in development which also brings along a few extra enhancements as a side effect, the largest being that /proc no longer shows any other process pid and is further restricted of what a process can know about itself.

 

Another security enhancement is moving to wolfSSL 4.4.0 bringing along additional side channel attack hardening. Along with the wolfSSL upgrade is work to begin exposing access to supported wolfSSL functionality, the first set of functions allowing customers to directly call wolfSSL for establishing TLS client connections.

 

We have added more fuzzing across 5 different components and additional static code analysis tools including extra static analysis tools on every pull request into our repositories. If the static analysis fails then the PR can not be completed, this further strengthens the system by making it more difficult to check in easy to abuse coding flaws. As we expand to add features and functionality more fuzzers are built for parts of the system being updated. The addition of the new static analysis tool detected an off by one calculation in DHCP message handling that allowed reading an extra byte of data past the end of the buffer, this was corrected in 20.07.

 

You may have noticed that our last couple quality releases did not have a Linux kernel patch bump, this time was used to allow the Linux kernel team to upgrade the Linux kernel from 4.9 to 5.4.44. By doing so we capture Linux kernel security enhancements done between the versions along with keeping up-to-date on the latest changes.

 

String manipulation functions are a very common way for leaking the stack cookie along with being able to write it when string buffers are not properly null terminated. GLibC helps limit string buffer attacks by forcing the first byte of the stack cookie in memory to be 0 however we use musl on the device for libc. Musl initializes all bytes in the stack cookie instead of leaving the first byte in memory 0 allowing for the potential of stack cookie leaks and abuses. Our version of musl in 20.07 sets the first byte to 0 and the patch was provided to the maintainer incase they wish to add this security measure to musl.

 

On top of our own changes, MediaTek provided a new version of the firmware for their WiFi subsystem of their MT3620 that is now being used on the platform to deal with a range of issues.

 

As you can see, a wide range of security improvements have been made to the platform as we continue to strive to be the best in the field. We will continue to be transparent about our efforts and are devoted to being the most secure platform for IoT.

 

Jewell Seay
Azure Sphere OSP Security Team Lead