fix: add bounds check before memcpy in crypto_lite.c#6
Conversation
Automated security fix generated by OrbisAI Security Signed-off-by: orbisai0security <mediratta01.pally@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request tightens validation in two cryptographic primitives: SHA-256 padding adds a bounds check to prevent out-of-bounds access, and AES-128 key expansion is refactored to accept and validate key length explicitly, improving robustness of both hash and cipher functions. ChangesCryptographic Algorithm Improvements
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fix critical severity security issue in
src/crypto_lite.c.Vulnerability
V-004src/crypto_lite.c:90Description: At src/crypto_lite.c:90, memcpy(block, data + i, rem) copies rem bytes from the input data buffer into block. If rem is derived from attacker-controlled stream data (e.g., the length field of an encrypted packet) without validation that rem <= sizeof(block) and that data+i does not exceed the source buffer, an out-of-bounds read from source or overflow into block occurs. At line 174, memcpy(rk, key, 16) unconditionally copies 16 bytes from key; if key is shorter than 16 bytes, an out-of-bounds read occurs. Both flaws are in the cryptographic processing hot path, directly reachable from network-delivered stream data.
Changes
src/crypto_lite.cVerification
Automated security fix by OrbisAI Security
Summary by CodeRabbit
Release Notes
Bug Fixes
Refactor