FUZ-22 - API Token improvements - Tool Segmentation #28
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.
Description:
This PR adds tool-specific segmentation to API tokens to enhance security in FuzzManager. Currently, API tokens have unrestricted access across all tools, creating potential security risks if compromised.
The changes:
add_tool_to_token
remove_tool_from_token
for token-tool management.This segmentation limits the impact of potential token leaks and provides better access control for crash/coverage reporting.
Demo
https://www.loom.com/share/bcde5c97bec54761a8a11b0f72a54850?sid=0b52a794-a0ad-478b-af24-5c254827e80b
Test Plan
Assign Tool to Token:
add_tool_to_token
management command to assign a specific tool to a token.python manage.py add_tool_to_token <token_string> <tool_name>
Verify Token Restrictions:
curl
to submit crash reports using the segmented token for the assigned tool.curl -H "Authorization: Token <token_string>" -X POST http://<server>/api/crashes/ -d '{"tool": "<tool_name>", "crash_data": "..." }'
curl -H "Authorization: Token <token_string>" -X POST http://<server>/api/crashes/ -d '{"tool": "unauthorized_tool", "crash_data": "..." }'
403 Forbidden
with a message indicating lack of permission.Ensure User Restrictions:
Tool Assignment:
python manage.py add_tool_to_token <token_string> <tool_name>
python manage.py remove_tool_from_token <token_string> <tool_name>