24

I have heard of programatically difference b/w GET and POST in web applications. Asking in curiosity which is more secure, GET method or POST method in web applications, I expect answers in terms of protocols too (i.e in http and https)?

1
  • @AliAhmad - Ha, too many browser tabs open? The link you posted is of this question. Not making fun, just happy I'm not the only one that this happens to. ;)
    – TildalWave
    Apr 6, 2013 at 19:53

3 Answers 3

43

POST is more secure than GET for a couple of reasons.

GET parameters are passed via URL. This means that parameters are stored in server logs, and browser history. When using GET, it makes it very easy to alter the data being submitted the the server as well, as it is right there in the address bar to play with.

The problem when comparing security between the two is that POST may deter the casual user, but will do nothing to stop someone with malicious intent. It is very easy to fake POST requests, and shouldn't be trusted outright.

The biggest security issue with GET is not malicious intent of the end-user, but by a third party sending a link to the end-user. I cannot email you a link that will force a POST request, but I most certainly can send you a link with a malicious GET request. I.E:

Click Here for the best free movies!

Edit:

I just wanted to mention that you should probably use POST for most of your data. You would only want to use GET for parameters that should be shared with others, i.e: /viewprofile.php?id=1234, /googlemaps.php?lat=xxxxxxx&lon=xxxxxxx

7
  • Similar to security.stackexchange.com/questions/30754/…
    – kinunt
    Apr 6, 2013 at 9:57
  • @david that example can be sovled with a CSRF token, but that's a whole different problem. Apr 6, 2013 at 10:22
  • Easy to share is not always a bad thing for a public web page/app.
    – themefield
    Aug 2, 2018 at 17:19
  • I'm scared to click that link. What's it do?
    – Marty
    Jun 12, 2019 at 21:31
  • @Marty Look at the link's address. It ends with "?newpass=hackedu" Jul 1, 2019 at 19:42
14

POST just puts the information in a different place (request message body) than GET (url). Some people feel like the latter exposes more information, which is true for some points (read down in the edit). From a point where an attacker would like to intercept your traffic, POST would be equally hard/easy for an attacker as for a GET.

If you want security so your request aren't exposed when it leaves end and start points, use SSL (https).

EDIT

A valid point of Gumbo and Ladadada, logging of GET requests can happen more frequently than POST requests. For instance in the history of a browser (if you share that browser with someone else).

So this means you shouldn't be putting sensitive data in a GET request as a GET request might be exposed to people who are screenwatching.

7
  • 2
    URLs show up and may be logged at various locations, e.g., the browser history, web server, proxies, etc.
    – Gumbo
    Apr 6, 2013 at 8:54
  • I agree on history and shared browsers, but if you can everything in end and start points (even POST requests) if you want to. Apr 6, 2013 at 9:32
  • @LucasKauffman Yes, you can view and alter GET or POST data, but that's only a point. There are other factors to evaluate if GET or POST is more secure.
    – kinunt
    Apr 6, 2013 at 9:55
  • Submitting a password field using GET would also circumvent the shoulder surfing protection that is normally provided by browsers.
    – Ladadadada
    Apr 6, 2013 at 10:13
  • I'm going to alter this answer. Apr 6, 2013 at 10:18
0

As @Gumbo says URLs are logged and appear in more places thus GET requests are a little more insecure than POST requests. The point is that a lot of people think that POST requests are much more secure than GET reqs because they can see the data directly in the URL but using, for example, a proxy software that intercepts browser requests anyone can view and alter POST data.

Another point is that you have to think where do you use GET and POST because GET should be used only for operations that do not alter database information, only request or read information and POST data should be used when data are going to be altered. Some web scanners click on every link automaticaly (usually GET requests) and not in buttons or forms (usually POSTS requests) avoiding altering the database but if for example you put a delete operation after a link you have the risk that the link could be clicked by more automated tools more easily.

Obviously, web scanners also can "click" or follow buttons and forms but usually they differenciate and this behaviour could be modified to spider the web safely.

1
  • 1
    Your first point is a bit moot. POST requests can be made a lot safer than GET requests could ever be, and with secure HTTP (or HTTPS) that difference is drastically increasing. You can't do much for information in URLs not to be disclosed in all kinds of logs, browser history, to shoulder surfers,... even when using SSL, however POST requests will be encrypted and could be thus considered safe on a safe connection (which might or might not be, see the answers in the linked question).
    – TildalWave
    Apr 6, 2013 at 20:24

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