Skip to content

Add bounds check iChanID before array access#3810

Merged
ann0see merged 1 commit into
jamulussoftware:mainfrom
ann0see:fix/oob-iChanID-audiomixerboard
Jul 21, 2026
Merged

Add bounds check iChanID before array access#3810
ann0see merged 1 commit into
jamulussoftware:mainfrom
ann0see:fix/oob-iChanID-audiomixerboard

Conversation

@ann0see

@ann0see ann0see commented Jul 20, 2026

Copy link
Copy Markdown
Member

Short description of changes

Guards iChanId to definitely be in bounds. Checking the flow revealed that there is indeed no other bounds check and we may have INVALID_INDEX (=-1) which would yield to an invalid access (found by AI review)

CHANGELOG: Resolve out of bounds access issue

Context: Fixes an issue?

No. Only discussed internally.

Does this change need documentation? What needs to be documented and how?

Status of this Pull Request

Ready for quick !! review. This is a potentially severe bug (as discussed internally)

What is missing until this pull request can be merged?

Review and testing

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see ann0see added this to the 3.12.3 milestone Jul 20, 2026
@ann0see ann0see added this to Tracking Jul 20, 2026
@ann0see ann0see added bug Something isn't working refactoring Non-behavioural changes, Code cleanup labels Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Jul 20, 2026
@ann0see ann0see moved this from Triage to Waiting on Team in Tracking Jul 20, 2026
Comment thread src/audiomixerboard.cpp

for ( size_t iFader = 0; iFader < iNumConnectedClients; iFader++ )
{
// ideally "iChanID" in CChannelInfo would be size_t if it can never be INVALID_INDEX

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the comment was wrong.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It includes the word if. The reason it's not size_t is because size_t is unsigned. As far as I'm aware, the comment is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. We still need to have an int then until after the check.

Comment thread src/audiomixerboard.cpp Outdated
@ann0see
ann0see force-pushed the fix/oob-iChanID-audiomixerboard branch from 8673697 to 098898b Compare July 20, 2026 13:08

@softins softins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

Although as a separate thing, I would prefer to make MathUtils::InRange() inclusive only of the lower bound, and exclusive of the upper bound, so that we could have MAX_NUM_CHANNELS as the upper bound instead of MAX_NUM_CHANNELS - 1, and similarly for the only other use of InRange(), which is in server.cpp

@dingodoppelt

Copy link
Copy Markdown
Member

Looks good to me.

Although as a separate thing, I would prefer to make MathUtils::InRange() inclusive only of the lower bound, and exclusive of the upper bound, so that we could have MAX_NUM_CHANNELS as the upper bound instead of MAX_NUM_CHANNELS - 1, and similarly for the only other use of InRange(), which is in server.cpp

Can we do that as part of this PR?

@ann0see

ann0see commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

No.

@dingodoppelt

Copy link
Copy Markdown
Member

No.

Created #3812

@mcfnord

mcfnord commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Worth merging: iChanID comes off the wire as an unvalidated unsigned byte (EvaluateConClientListMes, 0–255), and iFaderNumber is a stack-local int[150] — so a value in 150–255 is a server-controlled stack OOB write on every client. (Note the real risk is the upper bound; -1 can't arrive over the wire.) L1354 is the only wire-indexed write, so this closes it. The assumption has sat unenforced in-source since 2022. LGTM.

@ann0see ann0see added the AI AI generated or potentially AI generated label Jul 21, 2026
@pljones

pljones commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Once #3812 lands on main, this must go next. Then those two commits get ported to release/3_12 on on PR, please.

Switch bounds check to use MathUtils

Fix channel ID range check in audiomixerboard
@ann0see
ann0see force-pushed the fix/oob-iChanID-audiomixerboard branch from 098898b to 562cfd8 Compare July 21, 2026 19:00
@ann0see

ann0see commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

Rebased and updated

@pljones pljones added the backport_required A change to main that needs fix on an existing release. label Jul 21, 2026
@ann0see
ann0see merged commit 6e67ec4 into jamulussoftware:main Jul 21, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting on Team to Done in Tracking Jul 21, 2026
@ann0see
ann0see deleted the fix/oob-iChanID-audiomixerboard branch July 21, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI generated or potentially AI generated backport_required A change to main that needs fix on an existing release. bug Something isn't working refactoring Non-behavioural changes, Code cleanup

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants