[mac] verify that Security Level is correct in rx frame (#4905)

This commit adds a check in `Mac::ProcessReceiveSecurity()` to verify
that the Security Level in the received frame is properly set to
`kSecEncMic32` before trying to decrypt and validate the frame. This
helps avoid performing AES-CCM when frame is invalid and also avoid
potentially reading beyond the frame length when checking MIC/footer.
This commit is contained in:
Abtin Keshavarzian
2020-04-29 10:55:51 -07:00
committed by GitHub
parent 696d6389e6
commit 0877efe2eb
+2
View File
@@ -1446,6 +1446,8 @@ otError Mac::ProcessReceiveSecurity(RxFrame &aFrame, const Address &aSrcAddr, Ne
VerifyOrExit(aFrame.GetSecurityEnabled(), error = OT_ERROR_NONE);
aFrame.GetSecurityLevel(securityLevel);
VerifyOrExit(securityLevel == Frame::kSecEncMic32, OT_NOOP);
aFrame.GetFrameCounter(frameCounter);
otLogDebgMac("Rx security - frame counter %u", frameCounter);