Skip to content

bsc: reject short proprietary option headers in BVLC-SC decode - #1396

Merged
skarg merged 1 commit into
masterfrom
bugfix/out-of-bounds-in-bacnet-sc-proprietary-header-option-decode
Jun 19, 2026
Merged

bsc: reject short proprietary option headers in BVLC-SC decode#1396
skarg merged 1 commit into
masterfrom
bugfix/out-of-bounds-in-bacnet-sc-proprietary-header-option-decode

Conversation

@skarg

@skarg skarg commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • fix BACnet/SC proprietary header option validation to reject hdr_len < 3
  • guard proprietary decode fixed-offset reads ([3], [4], [5]) behind hdr_len >= 3
  • add regression test for malformed proprietary option (hdr_len = 2)

Security impact

A remote BACnet/SC peer could trigger heap out-of-bounds reads in proprietary header option decode before auth. This change blocks malformed options earlier and avoids unsafe fixed-offset reads.

Changes

  • src/bacnet/datalink/bsc/bvlc-sc.c
    • add validation failure for proprietary option header data length smaller than vendor-id + option-type (3 bytes)
    • decode function initializes outputs and only reads vendor-id / option-type when hdr_len >= 3
  • test/bacnet/datalink/bvlc-sc/src/main.c
    • add malformed packet case in test_BAD_HEADER_OPTIONS to verify decode rejects proprietary options with hdr_len < 3

Validation

  • targeted BVLC-SC unit tests:
    • cmake -S test/bacnet/datalink/bvlc-sc -B test/build-bsc-bvlc
    • cmake --build test/build-bsc-bvlc
    • ./test/build-bsc-bvlc/test_bvlc-sc
    • result: pass
  • pre-commit on changed files:
    • pre-commit run --files src/bacnet/datalink/bsc/bvlc-sc.c test/bacnet/datalink/bvlc-sc/src/main.c
    • result: pass

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens BACnet/SC BVLC-SC header option decoding by rejecting malformed proprietary header options that specify an invalid header-data length, preventing fixed-offset reads from occurring on too-short option bodies.

Changes:

  • Add BVLC-SC option header validation to reject proprietary options with hdr_len < 3 (minimum vendor-id + option-type).
  • Make proprietary option decode initialize outputs and only read vendor-id/option-type when hdr_len >= 3.
  • Add a regression test that injects a malformed proprietary option (hdr_len = 2) and asserts decode fails with ERROR_CODE_HEADER_ENCODING_ERROR.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/bacnet/datalink/bsc/bvlc-sc.c Adds stricter proprietary header option length validation and guards fixed-offset reads during proprietary option decode.
test/bacnet/datalink/bvlc-sc/src/main.c Adds a malformed proprietary-option test case to ensure decode rejects hdr_len < 3.

@skarg
skarg merged commit 1068250 into master Jun 19, 2026
37 checks passed
@skarg
skarg deleted the bugfix/out-of-bounds-in-bacnet-sc-proprietary-header-option-decode branch June 19, 2026 19:02
skarg added a commit that referenced this pull request Jul 2, 2026
* Add BVLC-SC option header validation to reject proprietary options with hdr_len < 3 (minimum vendor-id + option-type).

* Make proprietary option decode initialize outputs and only read vendor-id/option-type when hdr_len >= 3.

* Add a regression test that injects a malformed proprietary option (hdr_len = 2) and asserts decode fails with ERROR_CODE_HEADER_ENCODING_ERROR.
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.

2 participants