r/aws•
soldatz

Securing HTTP API Gateway?

technical question

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

29
sgtfoleyistheman•

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.

2
soldatzOP•

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?

1
sgtfoleyistheman•

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/

1
inphinitfx•

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.

0
sgtfoleyistheman•

can think of is asking the Angular developers to bake-in an authorization header with every request to the API

This makes me think the js client is talking directly to the API Gateway.

2
soldatzOP•

Yes, the Angular site is a SPA so all requests will be done by JS running in the user's browser.

1
inphinitfx•

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.

1
FileInfector•
1
letsgodaledo•

We just had this issue. I don't believe ACL / WAF are currently available for HTTP endpoints yet, only REST APIs. It forced us to migrate a product before rollout.

1