Information exposure alert on intentional input validation exception #16845
-
Is it possible to throw an exception on user input validation failure, and use the Exception.getMessage() to pass this onto the user, while allowing CodeQL scan to pass? I'm referring to a Java project. It appears a level of indirection is required such that Exception.getMessage() cannot be used. This appears to be a false positive though. I have a generic "InvalidInputException" that my validation method throws when it finds a user supplied parameter that is invalid. I'm not revealing any stack trace at all, just using the Exception.getMessage() method to carry a message to the user. CodeQL is saying:
Using Exception.getMessage() to carry a message actually intended for the user isn't even a stack trace. At a minimum this should be filed under something like "Information exposure through an Exception". Seems like user input validation cannot easily use an Exception to perform notification of validation failure. Bug or feature? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @slominskir, Thanks for you question. At first reading this does look like a false positive. However, from what you're writing it's not completely clear to me what your code is doing. Would it be possible for you to provide a more complete example? |
Beta Was this translation helpful? Give feedback.
Thanks at lot for the example. This indeed seems to be a false positive, as the stack trace is never output to the user.
Resolving false positives is not a current product priority, but I hereby acknowledge the report. If you would like us to track this properly, please open an issue. This will allow us to track this internally for future consideration, or if we observe repeated instances of the same problem.