-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Harden security: Switch to non-root user and sanitize error responses #12429
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
base: main
Are you sure you want to change the base?
Harden security: Switch to non-root user and sanitize error responses #12429
Conversation
|
Great PR, thank you! |
Lynn-Inf
left a comment
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.
To pass the Ruff check, you can log the exception locally before returning. For example, adding logging.error(str(e)) where the e variable is already in scope will satisfy the linter while preserving our error handling logic.
|
Thanks for the thorough review. I've updated the PR to address the security and logging concerns. Key changes:
Let me know if there's anything else that needs attention. |
|
@Lynn-Inf @KevinHuSh Just a quick heads-up: I've implemented the server-side logging and refined the Docker permissions as discussed. The CI should be back to green now. Mind taking another look when you have a moment? Thanks! |
|
@RinZ27 |
Lynn-Inf
left a comment
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.
LGTM on the error handling changes. For the Dockerfile user changes, my colleague @asiroliu will take a look and help out.
|
Thanks @Lynn-Inf and @asiroliu for the review and for catching the Nginx permission issue! I'm glad the error handling part is merged. Regarding the Docker non-root user changes, I understand why it was reverted to keep the build stable. The Nginx permission error ( If you're still interested in hardening the container security, I can open a separate PR to address just the Dockerfile changes. I'll make sure to adjust the Nginx configuration and directory permissions (e.g., |
|
This is fantastic to hear, thank you for your understanding and continued initiative! We greatly appreciate you offering to see this through. To keep the changes consolidated, could you please update the original PR/branch with the refined non-root user setup? Your approach of properly adjusting Nginx configurations and directory permissions (like Please feel free to push the additional commits to the existing branch. We'll review the entire set once you signal it's ready. Thanks again for driving this! |
|
Thanks @Lynn-Inf, good call on the Nginx permissions. I've updated the PR to include the non-root fixes. Switched Nginx to listen on 8080/8443 and moved the PID file to Compose configs are updated to map to the new internal ports. CI should be happy now. |
eeadb6f to
08df996
Compare
08df996 to
9f13725
Compare

Caught a couple of low-hanging security issues while poking around the admin routes and Docker setup.
First, the production Docker image was running as root. I've added a dedicated
ragflowuser and updated the permissions so we're not handing out root access by default—standard practice to minimize the blast radius if anything goes wrong.Second, I noticed we were piping raw exception strings (
str(e)) directly back to the client in several admin routes. That's a bit risky since it can leak internal paths or stack traces. I've sanitized those to return a generic "Internal Server Error" while keeping theAdminExceptionmessages intact since those seem intended for the user.Let me know if this looks good to you guys!