-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[CI] Remove print stacktrace (due to security concerns) #17597
Conversation
@mxnet-label-bot add [pr-awaiting-review] |
@anirudh2290 @access2rohit @marcoabreu |
Have you verified the security implications? Usually, these restrictions are in place for a reason - I'd recommend to first check why the developers considered that function security critical before moving forward. |
My point about security was a general point. I just made a note of it here. It can be verified here - http://jenkins.mxnet-ci.amazon-ml.com/scriptApproval/ |
The question is which security considerations have been put in place when the function was whitelisted |
Um it's a common practice to get the stack trace of errors and render them on Jenkins. A cursory glance on google search revealed lots of users doing that. I'm not sure if printing stacktrace poses security risk. |
Generally it's discouraged security wise to expose the stack trace of a system to the public since it offers insight into a protected system. Exceptions are generally logged into a system log which is only accessible to administrators. This is also the case for Jenkins. Printing the stack trace of the Jenkins master to public though is not something that's recommended. Printing the stack trace within docker is fine, within Jenkins though it's not. |
@marcoabreu The security concerns are well-founded. @access2rohit Do you mind explaining here why it was chosen to add printStackTrace to console despite its security concerns? Is it coz |
While MXNet might be open source, the Jenkins master is still are security relevant system. It contains credentials, has a user facing website and publishes artifacts. |
@ChaiBapchya This reference in your description goes to a 404. Publicly displaying your error logs isn't a great idea. Attacker could use it as a sounding board. |
Yes It is a 404 due to someone changing the job config. Removed the link from GitHub anyway to prevent any sec issue. |
Also #17065 introduced print stacktrace which got approved then by same folks. |
Jenkins already logs to the Jenkins error log which is only accessible by administrators. So I'd say there's no Todo except removing the security except. |
Mate, it doesn't matter who did what. You've identified a security issue and it's now on someone to fix it. The alternative is to have the PMC write an email to [email protected] and have a sev2 filed. I don't understand why we're still discussing this matter. |
Anyway! |
I understand and thanks for bringing it up. Sorry for being so hard on this, but it's difficult to compromise on security. Has the whitelist entry been removed? |
If I remove whitelist now before this gets merged, it will again block the jenkins build (due to that exception). |
Sounds good :) |
@mxnet-label-bot add [pr-awaiting-merge] |
* move error to console rather than system.err * remove printstacktrace
* move error to console rather than system.err * remove printstacktrace
Description
Right now with #17465 if a CI Jenkins build fails, we print the stacktrace using
error.printStackTrace()
functionI found that
a. According to Jenkins Script Security, It is an insecure function that needs to be approved by administrators in Jenkins -> Manage Jenkins -> In-process Script approval
Without the approval it gives SandBox error
This was probably the reason why status of few PR runs (despite success/fail on Jenkins) wasn't reported back to Github. Someone from the admin team likely approved it so as to allow the function to not error out.
b. However, the
error.printStackTrace()
function sends the report to System.errIt doesn't get printed on the console.
To print on console, it has to be passed as a parameter.
Verified it works by adding a failure case in the try (so as to enter the "catch")
It enters catch and then prints the stack trace for divide by zero exception as expected.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Comments
Read more about Jenkins Script Security : https://plugins.jenkins.io/script-security/
How to handle printStackTrace - https://stackoverflow.com/questions/12095378/difference-between-e-printstacktrace-and-system-out-printlne