Skip to content
Advertisement

Is there a reason that a browser would change its User Agent?

I’m currently working on a new website for a client that stores personal information and credit card info on the site. As such, security is a big concern for me. This is the first site I’ve built that has sensitive information on it, and so I’m not very familiar with the whole subject.

The site manages users using sessions. However, I’m finding it hard to keep the sessions secure. I want to implement a User Agent check that checks the browser every time a page is loaded. This way, when I copy the session ID into a manually-created cookie on my ‘attacker’ browser, the server will detect the user agent change (from Chrome to Firefox) and reject the session.

My question is, if I do implement this check to run EVERY time a page is loaded, do I run the risk of logging out my legitimate user? Is there any reason that the true user would change their user agent between pages? And if so, how likely is this to happen? Likely enough that I should abandon this approach entirely, or is it an acceptable risk?

EDIT: The cookies are set to expire as soon as the browser is closed. Also, the user agent that is set upon login is stored in the session and is hashed after a salt is appended to it.

Advertisement

Answer

Yes, the user-agent string can change. Session cookies often last longer than an individual browser session. If a user upgrades their browser (very common these days with the auto-updaters in Chrome and Firefox) then a different version will appear in the user-agent string.

In addition, some plugins are reported in the user-agent string, causing it to change if a user installs one.

Your user-agent string check doesn’t really offer any additional security. I don’t recommend it.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement