AWS WAF: Safe CDN, Load Balancers, API Servers – DZone – Uplaza

The introduction of software program has made outstanding adjustments to how enterprise is performed. “Back then,” folks would meet in particular person, and most corporations used guide strategies, which weren’t scalable. Software program has modified the sport, and internet functions are important for a enterprise’s success. Software program is how clients work together with companies, share their knowledge, and obtain items and providers.

Software program-as-a-service (SaaS) has change into a large trade, caring for internet hosting providers utilized by clients by upgrading, scaling, and securing buyer knowledge. With the huge proliferation of SaaS providers, many are utilizing AWS, and safety is a giant concern. Malicious actors search to steal buyer knowledge or DDoS-ing the service to stop official clients from accessing the web site.

It’s 2024, and we’re nonetheless combating the safety of hosted internet providers. The Mirai botnet has been one of the crucial profitable botnets, taking down huge corporations and creating variants of botnet code. Defending internet functions is a non-trivial downside, and the urgency of securing them at numerous levels of the structure can’t be overstated.

Drawback

Net functions face many issues, every various and complex in its personal proper. This implies our firewall guidelines should be created individually to deal with these issues.

DDoS Assaults

These assaults intention to inundate internet functions by sending them extreme visitors from quite a few compromised machines, rendering providers inaccessible to licensed customers.

Credit: Rustam, F., Mushtaq, M., Hamza, A., Farooq, M., Jurcut, A., & Ashraf, I. (2022). Denial of Service Assault Classification Utilizing Machine Studying with Multi-Options. Electronics, 11(22), 3817. 

SQL Injection

Attackers use utility code weaknesses to inject dangerous SQL statements, which might result in unauthorized entry to essential knowledge.

Credit: Alghawazi, M., Alghazzawi, D., & Alarifi, S. (2023). Deep studying structure for detecting SQL injection assaults based mostly on RNN autoencoder mannequin. Arithmetic, 11(15), 3286.

Cross-Web site Scripting

Malicious code is inserted into dependable web sites, operating in customers’ browsers and probably stealing precious info or taking management of person classes.

Cross-Site Scripting

Credit: Mwila, Ok. A. (2020). An evaluation of cyber assaults preparedness technique for private and non-private sectors in Zambia (Doctoral dissertation, The College of Zambia).

Cross-Web site Request Forgery

Attackers deceive customers into finishing up unintended actions on an online utility whereas they’re logged in.

Credit score: Cross-Web site Request Forgery (CSRF) Christopher Makarem by Christopher Makarem in IOCSCAN

Script Kiddies

Bots are used to robotically scrape content material, perform credential-stuffing assaults, or interact in different malicious actions.

Credit: What Is Credential Stuffing and How Can It Impression You? By Dashlane

The results of such assaults might be important and will end in compromised knowledge, monetary loss, service disruption, and long-term injury to an organization’s picture. The problem lies in creating a safety infrastructure that may adequately mitigate these dangers whereas additionally being versatile and able to increasing to counter new assault strategies.

Conventional internet utility firewalls often don’t successfully deal with these sophisticated challenges, significantly in cloud-native settings the place functions are unfold out in numerous native providers and areas. That is the place AWS WAF (Net Software Firewall) is essential, offering a deeply built-in answer for AWS clients.

Applied sciences

AWS WAF

AWS WAF is a versatile and sturdy service Amazon offers as a part of its AWS Suite.  From their web site, they make it very clear.

With AWS WAF, you possibly can create safety guidelines that management bot visitors and block frequent assault patterns corresponding to SQL injection or cross-site scripting (XSS).

Broadly, AWS WAF offers some basic constructing blocks utilizing which one can construct a sturdy safety system.

  1. Managed guidelines: Managed guidelines block frequent, well-known assault patterns. AWS creates and updates these guidelines, saving clients from reinventing the wheel.
  2. Customized guidelines: Not all assaults could be blocked utilizing managed guidelines. Some assaults are extra distinctive to a buyer’s service implementation and wish specialised dealing with. The shopper is chargeable for creating and updating these guidelines.
  3. IPSet is a set of IP addresses that one can use to allowlist or block. AWS offers a managed listing and clients can create their very own.
  4. Regex: Some assault patterns could be reused with minor variations. Might you create a regex sample and reuse it inside your customized guidelines?

AWS WAF has a WebACL idea, the place one can bundle the whole lot collectively as a single cohesive unit and connect it to supported AWS Service assets that must be protected.

AWS CloudFront CDN

AWS CloudFront is the flagship CDN product supplied by Amazon and securely delivers knowledge, pictures, movies, and any content material that the client needs thereby lowering latency if caching insurance policies are enabled. Together with the standard advantages of a CDN like decrease latency, it presents

  1. DDoS safety on the edge: The assaults don’t make it over to your servers.
  2. Caching region-specific static pages to considerably cut back shopping instances
  3. Encrypt the end-to-end expertise utilizing safe digital certificates.

AWS Software Load Balancer

AWS offers two sorts of load balancers: Community Load Balancer (NLB), which works on the L3/L4 layer of the networking stack, and Software Load Balancer (ALB), which works on the L7 utility layer. AWS WAF works totally on the L7 layer.  That is made abundantly clear by AWS WAF or AWS Protect.

For WAF to work, now we have to decide on ALB quite than NLB. Load balancers are alleged to be extremely obtainable by expectation, and if the attacker manages to compromise the load balancer, it defeats the first function. Utilizing AWS Protect and AWS WAF with ALB is the really useful answer.

AWS API Gateway

API Gateway is a totally managed cloud service that lets builders construct and deploy APIs, the commonest being REST APIs. It permits an authentication mechanism and is extremely scalable. Since most requests are served on the L7 or HTTP layer, attackers can ship specifically crafted requests to take advantage of any doable safety loopholes.

To mitigate this potential safety danger, we should always affiliate AWS WAF with API Gateway to handle points particular to this use case and this layer of the structure stack.

Methodologies

Block Totally different Sorts of Assaults at Totally different Phases

Not all assaults could be blocked in any respect locations of the cloud stack. Even when it may be, it may not be as environment friendly as one may assume. Primarily, we will block at three locations.

  1. CDN – Block regional assaults: It really works properly when the attackers will not be extremely distributed, however it works fairly properly even when they’re distributed all over the place. CloudFront has a number of Level-of-Presence (PoP) worldwide with storage and computing that can block malicious assaults on the first level of visitors ingress and spare the webservers from taking the brunt of such costly assaults. 
  2. Software Load Balancer: These are regional load balancers sitting contained in the AWS community, in all probability inside your subnet, and have the accountability of spreading the visitors load throughout a number of cases of your internet server. A lot of the frequent assaults needs to be blocked by the point visitors reaches ALB. At this layer, extra advanced and rarer assaults could be dealt with. 
  3. API Gateway: The API Gateway is the place the place we might deal with the particular assaults associated to API Design. The attacker could attempt to ship a malformed POST request that has the aptitude to trigger critical points. Such validations is perhaps too costly to implement in code. 

Totally different AWS Guidelines for Totally different AWS Assets

Fee Based mostly Guidelines

The very best place to place rate-based guidelines is on the sting, nearer to the customers. A whole lot of instances, we use IP-based rate-limiting. Relying on the implementation of the rate-limiting logic for that particular CDN, it is perhaps doable to be fairly environment friendly because the variety of IPs that may use a specific PoP is a a lot smaller subset of all the shoppers accessing that service. Within the case of CloudFront, there’s a PoP in San Francisco and Santa Clara, each throughout the better San Francisco Bay Space. Visitors from San Jose will probably be routed to Santa Clara PoP, and San Mateo or Oakland will probably be routed to San Franciso PoP. Every PoP has a smaller deal with area to compute the speed limits.

An instance of price based mostly rule is:

{
  "Name": "RateLimitRule",
  "Priority": 1,
  "Action": {
    "Block": {}
  },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "RateLimitRule"
  },
  "Statement": {
    "RateBasedStatement": {
      "Limit": 2000,
      "AggregateKeyType": "IP"
    }
  }
}

Maliciously Crafted Requests

Non-rate-limiting however low-effort high-volume assaults like Log4J or SQL injection assaults based mostly on commonest patterns could be finest blocked on the Edge itself. This ensures that the visitors that makes it to regional knowledge facilities is far smaller than the overall visitors despatched to the sting. 

Particular Headers Allowlist

In case your utility requires particular headers to be current, you possibly can permit them to be listed as the primary rule of your WebACL and set the default motion of WebACL to dam. This ensures that each one malformed HTTP requests will probably be blocked on the edge and considerably filters out undesirable visitors on the edge.

Validation Token

If you’d like your utility to comprise particular validation tokens in headers, you possibly can specify such guidelines within the WebACL related to the Software Load Balancer. This ensures that different providers in your group that wish to entry your service can instantly attain ALB throughout the AWS community itself. Placing these sorts of guidelines on ALB WAF ensures that they’re enforced for each inner and exterior customers. 

File Varieties

In case your API endpoint solely permits particular file kind uploads, that may be included within the WAF related to the API Gateway. Such restrictions could be carried out in utility logic, too, however if you wish to block an specific listing, then the WAF on the API Gateway could be a good selection.

JWT or API Key

In case your utility makes use of JWT for token-based authentication, the WAF guidelines can deal with such logic when related to API Gateway. We are able to use the identical place for API Key Validation. An instance of such a rule is:

{
  "Name": "ValidateJWTToken",
  "Priority": 5,
  "Action": {
    "Block": {}
  },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "ValidateJWTToken"
  },
  "Statement": {
    "NotStatement": {
      "Statement": {
        "ByteMatchStatement": {
          "SearchString": "Bearer ",
          "FieldToMatch": {
            "SingleHeader": {
              "Name": "Authorization"
            }
          },
          "TextTransformations": [
            {
              "Priority": 0,
              "Type": "NONE"
            }
          ],
          "PositionalConstraint": "STARTS_WITH"
        }
      }
    }
  }
}

Payload Limits

If we wish to implement Payload measurement limits, we will put them on both the sting, API, or ALB. There is no such thing as a appropriate reply, and it is determined by your enterprise logic. Ideally, it’s finest to place such guidelines on the sting to keep away from large knowledge switch prices, however it might probably additionally imply inner providers can bypass such limits.

Blocking Some Assaults in Software Logic

Not the whole lot could be blocked on the WAF guidelines stage since it may be too advanced to implement utilizing the standardized WAF syntax. Take, for instance, a Downgrade assault, the place the assault wish to exploit the backward compatibility nature of the design. Authentication validation techniques could be vulnerable to Go-The-Hash assaults, the place the attacker doesn’t have to de-hash the hashed password however tries to restart the session utilizing stolen hashed passwords. Code Injection assaults needs to be addressed within the code itself as we use code to validate the enter knowledge.

Total Design

A candidate design of the cloud structure. Various enterprise wants can change the general design. 

Conclusion

Utilizing AWS WAF with CloudFront, API Gateway, and Load Balancer created a sturdy and dependable structure. As cloud-native options, one can use AWS CDK to outline the code configuration, thereby explicitly following Infrastructure as Code patterns. We are able to tailor particular guidelines to particular levels and assets to create a seamless and environment friendly safety posture.

I might strongly recommend the engineers engaged on the cloud structure not contemplate any design to be set in stone. Common iterations and opinions are wanted to keep away from accumulating pointless technical debt. Utilizing AWS WAF wants to incorporate a correct operational plan and incident response plan. Keeping track of WAF Logs and extracting related metrics is essential in keeping track of the effectivity of the principles. I recommend fastidiously contemplating alarms based mostly on the enterprise wants and typical visitors patterns. The operational plan ought to define how such alarms behave, and the incident response plan ought to define what the on-call ought to do when particular incidents are in progress.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version