Skip to content

🔒 Secure DigiKey OAuth Token Storage Permissions - #9

Open
aman-katyal wants to merge 1 commit into
masterfrom
fix/digikey-token-permissions-11329927201123890868
Open

🔒 Secure DigiKey OAuth Token Storage Permissions#9
aman-katyal wants to merge 1 commit into
masterfrom
fix/digikey-token-permissions-11329927201123890868

Conversation

@aman-katyal

Copy link
Copy Markdown
Contributor

🎯 What: This PR fixes an insecure storage vulnerability where DigiKey OAuth access and refresh tokens were being written to a local file (digikey_token.json) with default system file permissions. It restricts the permissions of this file to 0o600 (read and write by the owner only).

⚠️ Risk: If left unfixed, the access and refresh tokens used for querying the DigiKey API could be accessible to other users on the same machine. This could lead to unauthorized access to the application's DigiKey quota, possible API abuse, or extraction of sensitive data.

🛡️ Solution: The fix replaces the simple open() call with os.open() using explicit os.O_CREAT | os.O_WRONLY | os.O_TRUNC flags and a mode of 0o600. Additionally, an explicit os.chmod() call is added to ensure that if the file already existed with more permissive settings, its permissions are correctly locked down. A unit test test_fetch_sourcing_bom.py has also been added to verify that the secure permissions are enforced.


PR created automatically by Jules for task 11329927201123890868 started by @aman-katyal

Replaced simple open() with os.open() using 0o600 permissions and
explicit os.chmod() when writing DigiKey token data to ensure
the file is only readable/writable by the owner.

Co-authored-by: aman-katyal <181611364+aman-katyal@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant