Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've got a bit of an argument at my workplace and I'm trying to figure out who is right, and what is the right thing to do.

Context: an intranet web application that our customers use for accounting and other ERP stuff.

I'm of the opinion that an error message presented to the user (when things crash) should include as much information as possible, including the stack trace. Of course, it has to start with a nice "An Error has occurred, please submit the below information to the developers" in large, friendly letters.

My reasoning is that a screenshot of the crashed application will often be the only easily available source of information. Sure, you can try to get a hold of the client's systems administrator(s), attempt to explain where your log files are, etc, but that will probably be slow and painful (talking to the client representatives mostly is).

Also, having an immediate and full information is extremely useful in development, where you don't have to go hunting through the log files to find what you need on every exception. (But that could be solved with a configuration switch.)

Unfortunately there has been some kind of "Security audit" (no idea how they did that without the sources... but whatever), and they complained about the full exception messages citing them as a security threat. Naturally, the clients (at least one that I know of) has taken this at face value and now demands that the messages be cleaned.

I fail to see how a potential attacker could use a stack trace to figure anything out he couldn't have figured out before. Are there any examples, any documented proof of anyone ever doing that? I think that we should fight this foolish idea, but perhaps I'm the fool here, so...

Who's right?

share|improve this question
16  
Wow. Just... wow. "Unfortunately there has been some kind of "Security audit"" - Seriously? What kind of attitude is that? The security audits are for your benefit - to make your systems better, to find the problems before the bad guys do. You should really consider trying to work with them, not against them. Also, you could try to get more information on the security PoV over at Information Security. –  AviD Aug 23 '12 at 18:42
4  
And btw, a security audit does not necessarily need access to the source code, they probably did a black-box penetration test, simulating what a malicious user would do - try to attack the application as a user. Though I agree that access to the source code could have enabled a much more effective form of audit. :-) –  AviD Aug 23 '12 at 18:44
1  
I agree very much about the weighing, but I disagree about its application. It harms security more than you think, and I also think that your way (having done this myself, too, until I talked to some of the users.....) is worse for usability. Think of it in task-oriented terms - as @Jon's answer said, his way gets the user's job done much better. The user doesnt need to care about the stack (unless your users are the developers...) But, my expertise is in security - and the risks are real. –  AviD Aug 23 '12 at 19:58
1  
e.g the sec.se question linked to by @oleksi - security.stackexchange.com/questions/4471/…. –  AviD Aug 23 '12 at 20:08
1  
If you have further questions along the same lines it would be better to ask them on Security Stack Exchange where the experts hang out. –  ChrisF Aug 23 '12 at 21:02
show 5 more comments

7 Answers

up vote 64 down vote accepted

I tend to build an application log, either in DB or in file, and log all such information to that. You can then give the user an error number, which identifies which log item the error is related to, so you can get it back. This pattern is also useful as you can follow errors even if the users don't bother raising them with you, so you can get a better idea of where the problems are.

If your site is installed in a client's environment and you can't reach it, you can get the on-site IT dept to send you some extract based on the error no.

The other thing you could consider is having the system email details of errors to a mailbox that you have sight of, so you know when things are going wrong.

Fundamentally having a system that spills its guts when something isn't right doesn't inspire confidence in non-technical users - it tends to scare them into thinking something is very wrong (eg how much of a BSOD do you understand, and how do you feel when one comes up)?

On stacktrace:

In .Net the stack trace will show the full trace right into the core MS sourced assemblies, and will reveal details about what technologies you're using, and possible versions as well. This gives intruders valuable info on possible weaknesses that could be exploited.

share|improve this answer
5  
I like your answer because it presents a "middle road" - don't show, but make the looking-up of exceptions easy. I'll try to push for that now, I hope that they will agree. Thank you! –  Vilx- Aug 23 '12 at 14:55
1  
I think this is pretty much the standard "mature" approach. Also, stacktrace does give a wealth of information, however I'm yet to find a solution which can automatically log state information along with the stacktrace (without code changes everywhere). It seems that writing your own debugger and attaching it is one possible way to go, but far from trivial to implement. –  Daniel B Aug 24 '12 at 12:09
    
@DanielB: In web apps its possible to get hold of some common stuff (like userid, clientid etc) from session/cache - as it's persisted "globally", even this much information can help reproducing errors greatly. More granular than that is very tricky through as you say. –  Jon Egerton Aug 24 '12 at 13:03
    
@JonEgerton good point, and I guess almost everything else you'd need to reconstruct the error is available in the Request object, in an easy-to-serialise format. But yes, I was mostly referring to non-web environments, local variables, etc. I guess the stateless nature of web applications is a big advantage in this regard. –  Daniel B Aug 24 '12 at 13:07
1  
@user1598390: Agreed, in which case the copying of the error details to a monitored support mailbox can expedite the gathering of information, to the point that the support staff know something is broken even before the user does. –  Jon Egerton Nov 5 '12 at 14:50
show 1 more comment

Yes, there are many.

A stack trace can reveal

  • what encryption algorithm you use
  • what some existing paths on your application server are
  • whether you are properly sanitizing input or not
  • how your objects are referenced internally
  • what version and brand of database is behind your front-end

... the list goes on and on. Basically every design decision in a large application might be security-relevant, and almost all of them may be given away through method or module names. Mind you, that doesn't mean it doesn't still make sense to display a stack trace if the environment it's submitted to is safe (e.g. an intranet rather than an internet-facing website), but the cost in security is defintely not zero.

share|improve this answer
5  
I agree for the most part, but some of these things shouldn't matter. For example, what encryption algorithm you are using shouldn't have to be secret to secure your system. –  Oleksi Aug 23 '12 at 14:47
2  
It shouldn't matter, but the world is imperfect, and often it does. That's why defense in depth (doing many things simultaneously that should be enough if they were perfect) matters. –  Kilian Foth Aug 23 '12 at 14:53
1  
Quite frankly, if a stack trace reveals anything that could help an attacker, then you are doing it wrong! –  Mark Booth Aug 23 '12 at 17:16
3  
@MarkBooth statistically speaking, you probably are doing it wrong. No, scratch that - statistical certainty that you are getting some of it wrong. Do you really want to let the attackers find your security bugs before you do? –  AviD Aug 23 '12 at 18:55
1  
@AviD - No, I agree, the most compelling reason to not display stack traces to users is that they have no idea what to do with them, and your logging system should be both secure and able to capture far more state than a screen grab of a web page ever could. –  Mark Booth Aug 24 '12 at 9:30
show 2 more comments

The thing is, it's not our primary job to make things easier on ourselves. It's our job to make things easier on the end user. To us, a stack trace looks like an extremely useful piece of information to provide a developer. To a user, it looks like complete gibberish that is of no use whatsoever. Even if you tell them otherwise, they don't internalize it. If you think it's hard getting that information from system administrators, getting it from end users is even worse.

As far as security goes, you might have a point if it was a desktop application. In that case, printing a stack trace doesn't provide anything an attacker doesn't already know. On a web app, that information isn't already available to an attacker. You are indeed exposing internal details that will make an attack a lot easier.

Why not bypass both sources of concern and get exception reports automatically sent to you? That way you don't even need to worry about people not reporting errors.

share|improve this answer
1  
The users benefits from a quick fix of his/her problem thanks to the info provides by the stack trace. But I get your point. –  user61852 Aug 23 '12 at 14:56
add comment

Take a look at this question of IT Security SE. In short, a stack trace can give the attacker more information to work with. The more information the attacker has, the more likely they are to penetrate your system. I wouldn't base my security on the fact that stack traces are always hidden, but that also doesn't mean that you should give that information to attackers.

You can get most of the benefits from proper backend logging anyway. It's slightly less convient, but it's probably not worth risking the secureness of your system and upsetting your customers.

share|improve this answer
add comment

You might consider not showing a stack trace for the following reasons.

Security

Showing a stack trace reveals possible attack surfaces to would be hackers. Intranets are not immune to hacking. It would reflect badly on you if your network was hacked because of an application you are responsible for

User Experience

For the user's best experience, a strack trace is too much information. Yes, the proper information about an error condition should be logged and given attention by an engineer. However, aksing a user to do what you can automate will not be the best for the user.

Your Reputation

Whenever a stack trace is shown on a website, it looks bad. Most people don't have any idea what it is and that makes them feel like the website isn't friendly to them. To those who do know what it is, it may be an indication that the application was not well thought out. Many badly written applications show stack traces way too often because it is the default in some frameworks like ASP.Net.

share|improve this answer
5  
As a Software developer, when I see a stack trace on the screen, my immediate though is "Here's a bozo who knows nothing about dealing with errors, cares less about them, and and probably even less about users". Others revolve around "this is crappy software, not on does it not work, its error handling doesn't work" and "WTF.... I'm not doing this guys job for him" What your user wants to know is what he needs to do to fix it. How does the stack trace do that. –  mattnz Aug 24 '12 at 1:55
add comment

Short answer: In an extranet or internet site, it makes sense not to show the stacktrace. In an intranet the benefits of showing the stacktrace surpass those of hiding it.

Long answer:

The same happened to me at work. I used to think that if an app fails, it should fail noisily.

But then they explained to me that a potencial hacker could infere a lot of things from a stacktrace.

I think there is no need for proof. Is evident that the more a hacker knows about your platform the better for him and that the less a hacker knows about your platform the better for you.

Also companies are not eager to disclose how a hacker broke into their systems.

On the other hand, it's an intranet, and I think that the advantages of knowing inmediatly what went wrong whitout having to search a log file is of great advantage and security risks of showing a stacktrace inside the boundaries of your company is not as high as they are saying.

share|improve this answer
1  
what are some of "the advantages of knowing inmediatly what went wrong", and why can't they be retrieved from a log file? It would seem that with an Intranet, you could access a log file even more easily than from a client site. –  Wonko the Sane Aug 23 '12 at 15:48
    
In my scenario, there are critical applications that have "7/24" priority. User call help desk, if the problem is an application error or exception, help desk calls the maintainer who maybe is off the premises. Whith the error info the expert can instruct an on-site person to a workaround... Often times the time saved is precious if the app is business-critical. if the expert that if off the premisses has first to connect to the company, search the log, etc., a critical business function could be waiting unnecessarily. –  user61852 Aug 23 '12 at 16:23
3  
@user1598390 so build a log viewing mechanism. A simple web page, input the incident id, and the helpdesk can see the entire relevant log. Of course limit access to this feature, and so forth... –  AviD Aug 23 '12 at 19:04
    
Just because an app is on your company's intranet doesn't mean there aren't malicious users on it. There are plenty of disgruntled employees out there who might very well misuse an internal system for their own benefit. Since these employees know a lot about the company and its policies they could actually be more dangerous than an internal hacker. Going through log files is a pretty trivial task, especially if you're following good practice and also log errors to a specific error log file. –  cliff.meyers Jul 25 '13 at 20:44
add comment

In any delivered product, the expected number of this type of error should be zero. The utility of this information to the customer is zero. On both counts, there's no reason to present a stack trace. If there is some useful context, it should be presented in a customer-friendly way, not as a stack trace.

On the other hand, if the actual number of occurrences isn't zero, you desperately need this information, and shouldn't rely on the customer to send it to you. 99.99% of the time they will not. You should install a bug reporing system that submits the information automaically, with only an "ok" from the customer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.