22

In relation to my question on programmers.stackexchange.com.

Is it a security risk to have your application display a full stack trace to the user when things crash? Some security audit that our application passed through says it is. I disagree. I don't see how that could help an attacker in any way.

Of course, there is the principle of "tell as little as possible", but that has to be balanced with common sense too, and I think that there is greater benefit of having that information easily available than risk of having it abused.

Have there been any studies about this? Any evidence at all that would suggest that this is a security risk? Or is this an overzealos application of the above principle?

1
  • Yes. OWASP has a good description of this. Commented Aug 29, 2013 at 21:38

3 Answers 3

18

A stack trace is an information leak, which reveals information about your implementation. Whilst not a serious vulnerability, it does allow an attacker to gain certain information about your system. It may also allow them to use a debugging-based approach to exploiting flaws in your site.

One might argue that the stack trace in itself is a vulnerability, since nobody should be able to crash your site in such a way.

Ignoring the security implications, it's not exactly confidence-inducing for your customers to see a stacktrace. They'll assume the site is broken (which it is, really) and worry about whether their transaction will work, or perhaps even think that the site has been hacked.

Further reading: Is it a vulnerability to display exception messages in an error page?

3
  • Can stack traces be in logs? Commented Aug 31, 2016 at 15:25
  • 1
    @pinkpanther Sure. It depends on the configuration of the OS and the application as to whether the stack trace is captured anywhere though.
    – Polynomial
    Commented Sep 1, 2016 at 9:45
  • 1
    This is very vague! "attacker to gain certain information about your system" - which info? What is a "debugging-based approach" other than debugging - if I can debug, I already have the code, I don't need a stack trace! Commented Nov 23, 2021 at 10:58
8

A stack trace is usually not a vulnerability in itself. However, it can leak some information about the design of the software, which may be helpful to the attacker (e.g., revealing database versions, table names, code filenames, and so on). Therefore, usually it is not a good idea to reveal the stack trace.

The standard way of dealing with this is: turn off stack traces on production servers. You can turn on stack traces on debugging builds that are not exposed to the outside world, to help you debug crashes, but when you move it into production, turn off stack traces.

The web2py web framework has an even more elegant way of dealing with this issue. web2py never reveals stack traces to visitors. Instead, if an uncaught exception occurs, web2py constructs a new "ticket", reveals a ticket number to the visitor, and saves the details of the error (e.g., stack trace, etc.) associated with that ticket in an internal database. Ordinary visitors cannot see the details of the ticket, but an administrator can. An administrator can look at the list of all tickets. In addition, given a ticket number, the administrator can look up its details of that ticket and see, e.g., the stack trace. From a security perspective, this is a great approach.

(Incidentally, web2py is an elegant framework that has put a lot of thought into making security on by default and easy for developers. web2py tries to eliminate security pitfalls and make your service secure by default, to the extent that it can. If you're building a web service that needs to be secure, take a look at web2py!)

1
  • 1
    That is a good answer. Very useful input about an architectural solution for keeping the stack trace associated with a specific incident without revealing any info to users. This avoids the problem of having to either search through logs to find the relevant stack trace, or reproduce an error in order to access the stack trace, both of which may sometimes be time consuming and problematic.
    – Kjartan
    Commented Apr 17, 2015 at 9:18
2

Yes, it is.

The best was one I came across that divulged ALL the database credentials on a webserver. Yup, you could remotely access the DB and run queries on it. Which probably means someone could do something nasty like DROP "databasename" or must more nicely, siphon off all the data in the database.

Another one I notified the owner about was a logged session where the stack trace showed the administration login name and unencrypted password.

Most stack traces are merely information leaks that will help someone in their nefarious activities, not quite as blatant as the first two examples given.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .