Skip to content

Ensure Secure File Permissions for Device Identity - #15

Open
kolega-dev-github-app[bot] wants to merge 1 commit into
mainfrom
kolega/fix-0d2b0920
Open

Ensure Secure File Permissions for Device Identity#15
kolega-dev-github-app[bot] wants to merge 1 commit into
mainfrom
kolega/fix-0d2b0920

Conversation

@kolega-dev-github-app

Copy link
Copy Markdown

Summary

This PR fixes a security vulnerability (CWE-732) related to insecure file permissions on the device identity file. It ensures the file is created and maintained with secure permissions (0600) to prevent sensitive cryptographic material from being accessed by unauthorized users.

Changes

  • Added a setSecureFilePermissions() function to safely set file permissions, handling errors securely
  • Implemented writeSecureFile() to create the identity file with secure permissions from the start, using a restrictive umask
  • Added verifySecurePermissions() to check the file permissions and throw an error if they are insecure
  • Updated the loadOrCreateDeviceIdentity() function to verify and enforce secure permissions on the identity file

Testing

The changes can be tested by creating a new device identity file and verifying the file permissions are 0600. Additionally, intentionally setting insecure permissions and ensuring the application fails securely.

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.

0 participants