fix: enforce inference restriction in SageMaker MME invoke handler - #8833
Merged
Conversation
SagemakerAPIServer::SageMakerMMEHandleInfer was missing the RETURN_AND_RESPOND_IF_RESTRICTED gate that HTTPAPIServer::HandleInfer and the SageMaker LIST/GET/LOAD/UNLOAD handlers use. Operators passing --http-restricted-api=inference,<hdr>,<val> expected the MME /invoke path to honor the restriction, but the handler silently accepted requests without the configured header. Add the macro call at the head of the handler so MME /invoke matches the rest of the HTTP inference surface. Extends qa/L0_sagemaker/test.sh with a regression block that exercises POST /models/<m>/invoke and POST /invocations both with and without the configured restriction header.
mc-nv
pushed a commit
that referenced
this pull request
Jun 13, 2026
…8833) SagemakerAPIServer::SageMakerMMEHandleInfer was not invoking RETURN_AND_RESPOND_IF_RESTRICTED, so the SageMaker MME /invoke path silently accepted requests without the configured inference header. Adds the macro call at the head of the handler and a regression test in qa/L0_sagemaker/test.sh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does the PR do?
Adds the missing
--http-restricted-api=inferenceenforcement to the SageMaker MME/invokehandler.SagemakerAPIServer::SageMakerMMEHandleInferwas not calling theRETURN_AND_RESPOND_IF_RESTRICTEDmacro, so the four sibling SageMaker control endpoints (LIST/GET/LOAD/UNLOAD) and the regular HTTP/v2/<m>/inferpath enforced the configured header while MME/invokesilently accepted requests without it. Adds the macro call at the head of the handler and a regression block inqa/L0_sagemaker/test.sh.Checklist
<type>: <description>Commit Type:
Related PRs:
N/A
Where should the reviewer start?
src/sagemaker_server.cc— one new line at the head ofSageMakerMMEHandleInfer:RETURN_AND_RESPOND_IF_RESTRICTED(req, RestrictedCategory::INFERENCE);This matches the four existing call-sites in the same file (LIST/GET/LOAD/UNLOAD, all gated on
RestrictedCategory::MODEL_REPOSITORY) andHTTPAPIServer::HandleInfer(gated onRestrictedCategory::INFERENCE).qa/L0_sagemaker/test.sh— new block that launches Triton with--http-restricted-api=inference:X-Auth=secretand exercisesPOST /models/<m>/invokeandPOST /invocationswith and without theX-Authheader. Expects403without and200with.Test plan:
Reproduced the BEFORE behavior on
nvcr.io/nvidia/tritonserver:26.05-py3:POST /models/<m>/invokewithoutX-Authreturned200 OKdespite--http-restricted-api=inference:X-Auth=secret. After the fix the same request returns403 Forbiddenwith{"error":"This API is restricted, expecting header 'X-Auth'"}.The new regression block emitted the expected codes on internal CI:
L0_sagemaker--base: passed (existing tests + new block)L0_http--base: passed (existinghttp_restricted_api_test.pyconfirms theRETURN_AND_RESPOND_IF_RESTRICTEDmacro is unchanged on non-SageMaker paths)Caveats:
None.
Background
SagemakerAPIServerextendsHTTPAPIServerand shares theRestrictedFeaturesmap viamain.cc(which copieshttp_restricted_apis_into theSagemakerAPIServerconstructor). The four sibling SageMaker control endpoints (LIST/GET/LOAD/UNLOAD) gate onRestrictedCategory::MODEL_REPOSITORY; the regular HTTP/v2/<m>/inferpath gates onRestrictedCategory::INFERENCE. The MME/invokehandler — which performs inference — was missing the gate. This PR adds the fifth call-site at the head ofSageMakerMMEHandleInfer(before any model resolution or dispatch) so behavior is consistent across all HTTP inference paths.Related Issues: (use Closes / Fixes / Resolves / Relates to)
N/A