[Bug]: VST3 getMidiControllerAssignment reads past midiControllerToParameter for program change

Open Beginner friendly
#1,810 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

Start in juce_audio_plugin_client_VST3.cpp at IMidiMapping::getMidiControllerAssignment and trace how MIDI controller indices are checked against midiControllerToParameter. Check the VST3 program parameter lookup, including the reported channel and controller boundaries. Done when program changes map to getProgramParamID() where available and invalid indices return kResultFalse; exercise the behavior for channels 0–15.

Written by the indexing model from the issue text.

Description

Detailed steps on how to reproduce the bug

With JUCE_VST3_EMULATE_MIDI_CC_WITH_PARAMETERS on (the default), a host that asks the VST3 controller which parameter handles MIDI program change calls IMidiMapping::getMidiControllerAssignment (bus, channel, Vst::kCtrlProgramChange, id).

juce_audio_plugin_client_VST3.cpp answers with midiControllerToParameter[channel][midiControllerNumber] and no range check. The table is [numMIDIChannels][Vst::kCountCtrlNumber], kCountCtrlNumber is 130 and kCtrlProgramChange is also 130, so this reads one past the end of the row: you get the CC 0 parameter of the next channel, and on channel 16 it reads past the whole array. The host then sends program changes to that parameter, so they never reach the plugin's program parameter.

To reproduce, load any JUCE VST3 with a few programs (the demo plugin works), get its IMidiMapping and call getMidiControllerAssignment (0, ch, Vst::kCtrlProgramChange, id) for ch 0..15. You get the bank select parameter of channel ch+1 instead of the program parameter, and garbage on channel 15. A user hit this in Reaper, where MIDI CC reaches the plugin but program change never does.

What is the expected behaviour?

Program change maps to the program parameter (getProgramParamID()) when the plugin has programs, and any channel or controller number outside the table returns kResultFalse instead of reading out of bounds.

Operating systems

Windows, macOS, Linux

What versions of the operating systems?

All, it's not OS specific.

Architectures

x86_64, ARM

Stacktrace
No crash, it's a silent out-of-bounds read in getMidiControllerAssignment.
Plug-in formats (if applicable)

VST3

Plug-in host applications (DAWs) (if applicable)

REAPER

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct
  • I agree to follow the Code of Conduct

I patched around it in the plugin where I hit it: https://github.com/tone-3000/tone3000-plugin/pull/306

Dominant language
C++
Stars
8.9k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from juce-framework/JUCE

All issues in juce-framework/JUCE

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.