I am designing an (as-RESTful-as-possible) API and would like to know how you would best solve the following:
GET /objects/{id}
{id}s
to be stored in our web server logs, so we want to avoid using querystring or URI params; which leaves us with params in the request body. (assume the data is such that the id is sensitive and we don't have access to another non-sensitive id)How can (should) we design the API GET
endpoint to avoid using query or URI params that could be logged?
Is it acceptable to use POST in this scenario or is there another creative way?
(Note: this API will NOT be exposed to third-parties)
Use HTTPS/TLS for REST APIs HTTPS and Transport Layer Security (TLS) offers a secured protocol to transfer encrypted data between web browsers and servers. Apart from other forms of information, HTTPS also helps to protect authentication credentials in transit.
The challenge is the REST API is case sensitive, so individual (person) names have to be an exact match, including case.
I think there are many services that are facing this problem of wanting to protect sensitive identifiers. However even though this question is some years old now, I didn't found a proper solution either.
The offered solution to simply alter the logging of your webserver isn't perfect as mentioned already, but also leaves out the fact that every client should to do the same while consuming your API (among which possibly JavaScript clients, via proxies, in browsers... good luck with that)
Solutions I am aware of are:
Encrypting the parameters; but this makes your API more complex, and it requires encryption keys.
use a pseudo-ID, as mentioned by @jj-geewax; however this is possibly even more complex than encyption (1) since you have to exchange a pseudo-ID for every sensitive parameter instance:
POST the parameters in the body, while requesting data; this is not REST
Solution 3 seems by far the most simple/easiest method to implement, although it breaks with the REST design rules. But I am interested to hear alternative approaches or other insights.
UPDATE: OWASP says the following regarding sensitive parameters in requests
Sensitive information in HTTP requests
RESTful web services should be careful to prevent leaking credentials. Passwords, security tokens, and API keys should not appear in the URL, as this can be captured in web server logs, which makes them intrinsically valuable.
- In POST/PUT requests sensitive data should be transferred in the request body or request headers.
- In GET requests sensitive data should be transferred in an HTTP Header.
https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html#sensitive-information-in-http-requests
This is maybe a bit harder than using the (POST) body, but also a lot nice when looking at how to implement REST.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With