Skip to content

User filter_parameter_logging for password

May 22, 2008

This morning while I was looking at some codes, I’ve found something
interesting. When I login, I looked at the logs and I could see clearly
the password that I’d just entered.


Parameters:{"commit"=>"Log in", "action"=>"create","controller"=>"sessions", "password"=>"password123","login"=>"foobar"}

I know, this looks like a trivial matter
but imagine anyone having access to our server looking at our
production logs file. Passwords are left wide open for the whole world
to see.

But no worries, just add this one liner in your application.rb

class ApplicationController < ActionController::Base
 filter_parameter_logging "password"


Go  back to your login form, fill in your login name and password and then  submit. Check out the logs and see the parameters hash.

&#91;sourcecode language="ruby"&#93;
Parameters: {"commit"=>"Log in", "action"=>"create","controller"=>"sessions", "login"=>"foobar","password"=>"[FILTERED]"} 

Notice the hash key ‘password’?

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: