Skip to content

cid: harden CID string parsing bounds#15

Merged
uink45 merged 1 commit intomainfrom
codex/cid-string-bounds-hardening
Feb 15, 2026
Merged

cid: harden CID string parsing bounds#15
uink45 merged 1 commit intomainfrom
codex/cid-string-bounds-hardening

Conversation

@uink45
Copy link
Collaborator

@uink45 uink45 commented Feb 15, 2026

Summary

  • add bounded string-length scanning in CID text decode paths to avoid unbounded strlen() reads
  • add explicit CIDV1_MAX_STRING_LENGTH contract and enforce it in cid_v1_from_string()
  • extend CIDv0/CIDv1 tests for oversized and unterminated string inputs

Validation

  • cmake --build --preset macos-full --target cid_v0 cid_v1 test_cid_v0 test_cid_v1
  • ctest --preset macos-full -R '^(Testcid_v0|Testcid_v1)$' --output-on-failure
  • ctest --preset macos-full -R '^(Testmultibase|Testcid_v0|Testcid_v1)$' --output-on-failure
  • clang-format --style=file --dry-run --Werror include/multiformats/cid/cid_v1.h src/multiformats/cid/cid_v0.c src/multiformats/cid/cid_v1.c tests/multiformats/cid/test_cid_v0.c tests/multiformats/cid/test_cid_v1.c
  • cppcheck --error-exitcode=1 --std=c99 --enable=warning,portability --quiet --suppress=missingIncludeSystem src/multiformats include/multiformats tests/multiformats src/peer_id include/peer_id tests/peer_id
  • cppcheck --std=c99 --enable=all --check-level=exhaustive --quiet --suppress=missingIncludeSystem --suppress=':tests/' --addon=/opt/homebrew/share/cppcheck/addons/misra.py -I include src/multiformats/cid include/multiformats/cid tests/multiformats/cid

@uink45 uink45 merged commit 2523f14 into main Feb 15, 2026
3 checks passed
@uink45 uink45 deleted the codex/cid-string-bounds-hardening branch February 15, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant