-
Notifications
You must be signed in to change notification settings - Fork 7.4k
tinycbor buffer overflow causing mcumgr image upload failure #19629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
@nvlsianpu, can you provide some guidance on priority level for this problem? |
@jimparis zephyrproject-rtos/tinycbor#7 Is this full fix for the issue? |
As far as I'm aware yes, for tinycbor. Then an update to zephyr's west.yml here to point to the new version. Then the workarounds in mcumgr could be removed, but they are harmless. |
@carlescufi is already updating west.yml manifest here: #19838 |
carlescufi
added a commit
to carlescufi/zephyr
that referenced
this issue
Oct 16, 2019
Point to the current revision at the tip of the tinycbor repo after merging zephyrproject-rtos/tinycbor#7. Fixes zephyrproject-rtos#19629. Signed-off-by: Carles Cufi <[email protected]>
carlescufi
added a commit
that referenced
this issue
Oct 16, 2019
Point to the current revision at the tip of the tinycbor repo after merging zephyrproject-rtos/tinycbor#7. Fixes #19629. Signed-off-by: Carles Cufi <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Hi,
Reporting this here because zephyrproject-rtos/tinycbor doesn't have an issue tracker.
There is a buffer overflow in zephyr's tinycbor, in cborparser.c:
If
iterate_string_chunks
fills the buffer completely, the byte past the buffer is zeroed. This is in contrast to the function comment, which says "If the buffer is large enough, this function will insert a null byte after the last copied byte".The bug is not present in the upstream intel/tinycbor, where they add termination inside
iterate_string_chunks
instead.The bug was introduced by zephyrproject-rtos/tinycbor#1, which appears intended to bring the code more in-line with the upstream mynewt tinycbor, but their code doesn't have the bug either.
The specific symptom I'm seeing is:
and it's happening because
data_sha
overflows intoimg_mgmt_data
inimg_mgmt_upload
, during acbor_read_object
call:which clobbers the
IMAGE_MAGIC
checked byimg_mgmt_check_header
.This same tinycbor bug was the root cause of an earlier mcumgr fix in #7924, which ended up in a patch to upstream's mcumgr apache/mynewt-mcumgr#5. There, it was noted by @ccollins476ad that it was actually a zephyr tinycbor bug, but the workaround was merged to mynewt's mcumgr anyway (apache/mynewt-mcumgr@c2da8ca), and then also into zephyr's fork (zephyrproject-rtos/mcumgr@d9b889e).
I think both of those commits should be reverted in their repos once this is fixed.
The text was updated successfully, but these errors were encountered: