-
Notifications
You must be signed in to change notification settings - Fork 985
Improve network name validation #16068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve network name validation #16068
Conversation
Signed-off-by: Simon Deziel <[email protected]>
Signed-off-by: Simon Deziel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves network name validation by centralizing validation logic and adding path traversal protection. The changes strengthen security by preventing directory traversal attacks through malicious network names.
- Adds centralized validation using
shared.IsFileName()to prevent path traversal attacks - Replaces inline string checks with calls to the centralized
ValidateName()method - Refactors path handling to use variables for better readability and maintainability
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lxd/network/driver_common.go | Adds path traversal protection to ValidateName() and improves path handling in rename() |
| lxd/network/driver_bridge.go | Replaces inline validation with centralized ValidateName() calls and fixes variable reuse |
| if shared.PathExists(shared.VarPath("networks", n.name)) { | ||
| err := os.Rename(shared.VarPath("networks", n.name), shared.VarPath("networks", newName)) | ||
| if shared.PathExists(oldNamePath) { | ||
| err := os.Rename(oldNamePath, newNamePath) |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
| if shared.PathExists(shared.VarPath("networks", n.name)) { | ||
| err := os.Rename(shared.VarPath("networks", n.name), shared.VarPath("networks", newName)) | ||
| if shared.PathExists(oldNamePath) { | ||
| err := os.Rename(oldNamePath, newNamePath) |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Signed-off-by: Simon Deziel <[email protected]>
…rename forkdns log file Signed-off-by: Simon Deziel <[email protected]>
deae3e5 to
ef6ce13
Compare
No description provided.