Securing HTTP API Gateway?
Hi, team.
We're working on an Angular site hosted on-prem that interacts with an AWS HTTP API Gateway.
The Gateway has an integration to our private subnets: a private ALB communicating to our ECS cluster of services, various stages, etc.
So far I've only protected the API Gateway with CORS.
It works fine, but I want to know is, what if someone decides to start snooping around and use curl or some other tool to probe the API? CORS doesn't protect against this.
How do I secure the API gateway in the dumbest, simplest way possible on the AWS side? The only way I can think of is asking the Angular developers to bake-in an authorization header with every request to the API, and then I use a Lambda authorizer.
What am I missing?
Posted Mar 6, 2021, 3:19 AM UTC · edited
I would work backwards from the users of the website. How do they login to your website? What kind of identities do they have?
Baking in some constant header isn't protection, as there's nothing stopping an attacker from taking this from network sniffing or the website code.
The users will authenticate with our Azure AD via SAML and get a cookie before the Angular site allows them to proceed and hit the API.
Any way to leverage this?
I haven't used ADFS or SAML so not familiar with some of the details of how this is setup.
But if you can get a token into your headers/cookies to the API, you can validate it in the lambda authorizer.
You can also federate these users into Cognito, which will perform the SAML validation and give you cognito JWT refresh/access tokens with claims ontop of your SAML identity. This is a bit more complex though: https://aws.amazon.com/blogs/mobile/building-adfs-federation-for-your-web-app-using-amazon-cognito-user-pools/
If the hosted site is sending the requests to the APIGW, the user has no visibility of this (assuming proper implementation), and would need to compromise the web server -> apigw connection to sniff the traffic assuming it's implemented properly. Sending a token in an auth header in this situation would be a reasonable step - depending on the assessed risk of the apigw being compromised.
This makes me think the js client is talking directly to the API Gateway.
Yes, the Angular site is a SPA so all requests will be done by JS running in the user's browser.
Then I agree with sgtfoleyistheman, it adds basically no security to auth it that way, as any visitor can easily capture the details.
Honestly, I would revisit the overall architecture of the solution.