Security: require API key for firmware snapshot endpoint (VULN-002)#115
Open
tobiasmcnulty wants to merge 6 commits intomainfrom
Open
Security: require API key for firmware snapshot endpoint (VULN-002)#115tobiasmcnulty wants to merge 6 commits intomainfrom
tobiasmcnulty wants to merge 6 commits intomainfrom
Conversation
tobiasmcnulty
commented
Mar 23, 2026
Co-authored-by: Tobias McNulty <tobias@caktusgroup.com>
Member
Author
|
@copelco @simonkagwi What do you think of this change? We could add the API key to the firmware app's managed configuration (or even generate and push it out automatically via Publish MDM). Probably a good idea long-term, and there's no harm in adding this now since it's not actively in use? |
simonkagwi
approved these changes
Mar 23, 2026
Contributor
simonkagwi
left a comment
There was a problem hiding this comment.
Looks good to me, I just have one small suggestion on the comment in the settings file. Adding the API key to the app's managed configuration sounds good too. 👍
Co-authored-by: simonkagwi <skagwi@caktusgroup.com>
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.
Fixes #113.
Summary
Adds mandatory
MDM_FIRMWARE_API_KEYbearer-token authentication tofirmware_snapshot_view. Requests without a valid key receive HTTP 401. If the key is not configured in the environment, the endpoint also returns 401 (previously it was silently unauthenticated).Key changes
config/settings/base.py: newMDM_FIRMWARE_API_KEY = os.getenv("MDM_FIRMWARE_API_KEY", "")settingapps/mdm/views.py: mandatory auth gate before any body parsing; missing key now returns 401 instead of logging a warningtests/mdm/test_security.py(new):TestFirmwareSnapshotAuth— regression tests for unauthenticated, correctly-keyed, wrong-keyed, and missing-key casestests/mdm/test_views.py(new onmain):TestFirmwareSnapshotViewwithset_api_keyautouse fixture so that existing functional tests pass under mandatory authRequired Operator Action
Set
MDM_FIRMWARE_API_KEYin the environment and update all firmware-reporting devices to includeAuthorization: Bearer <key>.Conflict resolution note
This cherry-pick spans two commits from
99-policy-editor-v2(d6fa0ceandc574a04).d6fa0cealso contained unrelatedpolicy_addview changes (scoped to the feature branch's policy editor refactor) which were excluded during conflict resolution.tests/mdm/test_views.pydoes not exist onmain; a minimal file was created containing onlyTestFirmwareSnapshotView.Cherry-picked from
Commits
d6fa0ceandc574a04on99-policy-editor-v2.