Add adapter security validation to Secure Mode plugin#2970
Merged
Conversation
- Add SecureModeAdapterValidator for validating LoRA adapters - Validate adapters for model.py, requirements.txt, and pickle files - Support both static (workflow) and dynamic (API) adapter loading - Add 17 comprehensive unit tests for adapter security - Refactor shared validation logic to SecureModeUtils - Update README with adapter security documentation - All tests passing (38 total: 21 plugin + 17 adapter) - All linting checks passing (checkstyle, PMD, SpotBugs) - Fix Python formatting in tests/integration/tests.py Adapters are now validated at creation time before registration, ensuring they cannot bypass Secure Mode restrictions. Failed adapters are not created or registered, and do not appear in the LIST API. Security controls validated for adapters: - DISALLOW_CUSTOM_INFERENCE_SCRIPTS (model.py) - DISALLOW_REQUIREMENTS_TXT (requirements.txt) - DISALLOW_PICKLE_FILES (.bin, .pt, .pth, .ckpt, .pkl) Fixes: Adapters could previously bypass Secure Mode validation
6b56b5c to
12388a2
Compare
Member
Author
|
Existing integ tests passing - https://github.com/deepjavalibrary/djl-serving/actions/runs/19939252132 |
ethnzhng
reviewed
Dec 4, 2025
plugins/secure-mode/src/main/java/ai/djl/serving/plugins/securemode/SecureModePlugin.java
Outdated
Show resolved
Hide resolved
…emode/SecureModePlugin.java Co-authored-by: ethnzhng <26497102+ethnzhng@users.noreply.github.com>
ethnzhng
approved these changes
Dec 5, 2025
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.
Follow up to #2951
Adapters are now validated at creation time before registration, ensuring they cannot bypass Secure Mode restrictions. Failed adapters are not created or registered, and do not appear in the LIST API.
Security controls validated for adapters:
Fixes: Adapters could previously bypass Secure Mode validation
Type of change
Please delete options that are not relevant.
Checklist:
pytest tests.py -k "TestVllm1" -m "vllm"Feature/Issue validation/testing
Please describe the Unit or Integration tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.
Test A
Logs for Test A
Test B
Logs for Test B