Hello, I currently have a lambda / api gateway backend backed by Cognito.
I understand that API Gateway uses HTTPS, so headers like authentication token are concealed from Man in the middle attacks.
However, does HTTPS prevent the CLIENT from reading the request headers? Could a client find out their access token by viewing their outgoing or incoming web traffic or by any way?
Depends on what the client is in terms of technology but as the client is making an HTTPS request to your API gateway, the client can also see the details of that request.
With Javascript-based clients, this is always true. That’s the reason you usually used short-lived tokens generated for the specific client and not a “global” token.
This is a mobile app. I’ve always known you can’t truly know if a request is coming from the mobile app, because login endpoints are public and malicious users could login to cognito endpoints, get their access token, then make malicious requests to my server.
However, google introduced AppCheck, which performs some sort of attestation to verify that the request comes from the app. I understand this would stop use of the public endpoint, but what’s stopping the user from just viewing their https traffic through some sort of scheme and just sending over the attestation certificate with it?
Assume that the client can almost always read the HTTP/HTTPS request headers. I assume the client and requests are 100% attacker controlled from a threat modeling perspective.
A decrypting TLS proxy set up between their mobile device and your API Gateway will allow them to obtain the access token.
You could attempt to prevent both of these by shipping an app with your TLS intermediate signing certificate or root in the app. No dev tools and no ability to decrypt on a proxy since your app would do its own TLS server certificate chain validation on top of the OS’.
It’s still a paper shield since the client can likely be decompiled and modifed to replace your pinned certificates by an attacker.
Just to be clear on “client”: So I know my mobile app code itself will be able to read the http data, but the user of the phone will be able to read the data?
So app check will prevent users from being able to use their tokens gotten from public Cognito login endpoints and keep them from making malicious requests from Postman with that access token (because server expects app check certificate), UNLESS they manage to copy over the certificate (by reading their outgoing HTTPS request) and send it from postman imitating a real device?
The client fully decrypts HTTPS traffic when it receives it. It then encrypts it again going out. There’s no reason for the client to NOT decrypt it because it wants to know what the server sent.
Also the Request headers are formed by the client. It’s literally meta data from the client about what the client is requesting.
Rule of thumb is confidential data on a device is no longer confidential to that device even despite encryption.
My question was a little confusing. By the “client,” I mean the user who owns the device running my app. I understand my app code (which is a client to the server, but trustworthy, as Ive written it) will see the plain http, but could the user running my mobile app intercept it plain on their phone?
Yes, there is nothing in the HTTPS protocol to prevent the user from finding and reading the http payload… They might need to install some http debugging apps or some such, but yes, they can.
In general, I know my client app is providing genuine requests, as I wrote the code. I know those requests will be good with the server.
if a malicious user read their own access token, they could then make requests to my backend outside of the context of my app and try to enter data that causes issues. I have good schema validation on my backend, but you can only account for so many cases.
You are correct. That is totally possible and totally what attackers would do. You need to think about ways to improve your application (server side) to deal with that attack vector.
Server side validation always needs to be 100% regardless of the source of requests. It’s a pain in the ass but it’s not that hard or time consuming in the grand scheme of things
A normal user will only see what you want. A skilled security expert will be able to access any information stored on a device they have physical access to.