armadietto icon indicating copy to clipboard operation
armadietto copied to clipboard

In Production mode, responses should not leak information

Open DougReeder opened this issue 3 years ago • 2 comments

When NODE_ENV=production is set in the environment

  • "Username not found" -> "The user name and password don't match"
  • "Incorrect password" -> "The user name and password don't match"
  • error.message should never be displayed, only an appropriate message or "An error occurred".

Other responses might need to be changed as well.

The log must still contain the details we hide from end users.

DougReeder avatar Feb 01 '22 18:02 DougReeder

I would like to work on this. I took a look at the code and, currently, the only error that auth.html expects is a 401 Unauthorized. Since the log must still contain the error details, we could change the response only on the auth view when process.env.DEBUG is set.

   <% if (typeof error !== 'undefined') { %>
-    <p class="error"><%= error %></p>
+    <% if (process.env.DEBUG) { %>
+      <p class="error"><%= error %></p>
+    <% } else { %>
+      <p class="error">Login failed - Incorrect username or password</p>
+    <% } %>
   <% } %>

Let me know if you have any comments so I can make a PR or if you already have a plan for this =)

andersonjoseph avatar Feb 25 '22 05:02 andersonjoseph

That's very close to what I'm thinking! I think we should use NODE_ENV here rather than DEBUG.

We should also change line 14 of contrib/systemd/armadietto.service to Environment=NODE_ENV=production

DougReeder avatar Feb 25 '22 14:02 DougReeder