Skip to content
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

[Fix](http)Enhanced Security Checks for Audit Log File Names (#44612) #46007

Closed
wants to merge 1 commit into from

Conversation

CalvinKirs
Copy link
Member

…44612)

## Purpose:

To improve the security of audit log files, a new method
checkAuditLogFileName has been added to validate the file name and path
to ensure they meet security requirements. This method is designed to
prevent invalid file names and path traversal attacks, ensuring that
only files within the designated directory can be accessed.↳

### Changes:

#### File Name Validation:

A regular expression check has been added to validate the file name:
^[a-zA-Z0-9._-]+$, restricting the file name to letters, numbers, dots,
underscores, and hyphens.

If the file name contains invalid characters (e.g., spaces, path
traversal characters), a SecurityException is thrown with the message
“Invalid file name.”
Path Validation:

The file name is resolved into a normalized path, and it is checked to
ensure that it is within the allowed directory.

The path is constructed using
Paths.get(Config.audit_log_dir).resolve(logFile).normalize(). If the
path does not start with the specified audit log directory
(Config.audit_log_dir), indicating an attempt to access outside the
permitted directory (e.g., a path traversal attack), a SecurityException
is thrown with the message “Invalid file path: Access outside of
permitted directory.”

(cherry picked from commit c0b8478)
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@CalvinKirs
Copy link
Member Author

run buildall

@CalvinKirs CalvinKirs closed this Dec 26, 2024
@CalvinKirs CalvinKirs deleted the branch-2.0-44612 branch December 26, 2024 07:21
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.

2 participants