• The API Platform for AI.

      Explore More
      Platform Runtimes
      Kong Gateway
      • Kong Cloud Gateways
      • Kong Ingress Controller
      • Kong Operator
      • Kong Gateway Plugins
      Kong AI Gateway
      Kong Mesh
      • Kong Mesh Policies
      Platform Core Services
      • Gateway Manager
      • Mesh Manager
      • Service Catalog
      Platform Applications
      • Developer Portal
      • API and AI Analytics
      • API Products
      Development Tools
      Kong Insomnia
      • API Design
      • API Testing and Debugging
      Self-Hosted API Management
      Kong Gateway Enterprise
      Kong Open Source Projects
      • Kong Gateway OSS
      • Kuma
      • Kong Insomnia OSS
      • Kong Community
      Get Started
      • Sign Up for Kong Konnect
      • Documentation
    • Featured
      Open Banking SolutionsMobile Application API DevelopmentBuild a Developer PlatformAPI SecurityAPI GovernanceKafka Event StreamingAI GovernanceAPI Productization
      Industry
      Financial ServicesHealthcareHigher EducationInsuranceManufacturingRetailSoftware & TechnologyTransportation
      Use Case
      API Gateway for IstioBuild on KubernetesDecentralized Load BalancingMonolith to MicroservicesObservabilityPower OpenAI ApplicationsService Mesh ConnectivityZero Trust SecuritySee all Solutions
      Demo

      Learn how to innovate faster while maintaining the highest security standards and customer trust

      Register Now
  • Customers
    • Documentation
      Kong KonnectKong GatewayKong MeshKong AI GatewayKong InsomniaPlugin Hub
      Explore
      BlogLearning CentereBooksReportsDemosCase StudiesVideos
      Events
      API SummitWebinarsUser CallsWorkshopsMeetupsSee All Events
      For Developers
      Get StartedCommunityCertificationTraining
    • Company
      About UsWhy Kong?CareersPress RoomInvestorsContact Us
      Partner
      Kong Partner Program
      Security
      Trust and Compliance
      Support
      Enterprise Support PortalProfessional ServicesDocumentation
      Press Release

      Kong Advances Konnect Capabilities to Propel Today’s API Infrastructures into the AI Era

      Read More
  • Pricing
  • Login
  • Get a Demo
  • Start for Free
Blog
  • Engineering
  • Enterprise
  • Learning Center
  • Kong News
  • Product Releases
    • API Gateway
    • Service Mesh
    • Insomnia
    • Kubernetes
    • API Security
    • AI Gateway
  • Home
  • Blog
  • Learning Center
  • Building and Securing API Gateway Architecture
Learning Center
March 10, 2022
4 min read

Building and Securing API Gateway Architecture

Kong

As with all content accessed over the internet, APIs and API gateways are vulnerable to myriad threats if not properly secured. Without appropriate authentication and authorization in place, your application can be accessed by anyone who cares to look.

API Security

If the connection from clients to your API gateway isn't encrypted, all messages you send and receive are out in the open for all to read. In looking for a way in, attackers will make use of all features of an API, even the undocumented ones; security by obscurity is not a realistic defense measure.

By definition, APIs provide programmatic access to your application, making them a large attack vector for malicious actors. Brute force attacks can be used to discover login credentials, giving attackers access to a user's account and a platform from which to seek out more vulnerabilities. By including invalid content in an API request, malicious code can be injected directly into a system; SQL injection and cross-site scripting are the best known forms of this attack. Denial of service and distributed denial of service attacks can be used to take an application offline by hitting it with more requests than it can handle and consuming all its resources.

Securing an Existing API Gateway

An API gateway decouples the backend microservices from the public interface of your application, providing a central access point for your APIs. While this simplifies access to the application for clients, it also provides a central platform for implementing security best practices, applying them consistently to all your APIs.

HTTPS Communication

Whether you've inherited an existing API gateway or you're conducting a security audit of your existing setup, one of the first items on your list should be to ensure all communications between the API gateway and clients are sent over HTTPS, even if authentication is not required. For content that should be restricted to logged in users, a reliable, secure authentication method is essential. This includes following API authentication best practices to make it much harder for attackers to impersonate a valid user by discovering their username and password. Both of these features can be implemented at the API gateway level, rather than on the individual microservices. This avoids duplication of effort for developers and ensures a consistent approach across your application.

API Threat Defense

When defending against other types of threat, such as denial of service, brute force and injection, an API gateway offers an additional line of defense. While injection attacks can be guarded against with server-side and client-side validation on the data being sent, a regex check at the API gateway can prevent malicious code reaching the server side. Rate limiting, request/response size limiting and throttling can be used not just to manage spikes in activity but to defend against repeated calls from attackers or bots. Adding logging to an API gateway provides an audit trail for all calls made to your APIs, so you can verify what data has been accessed.

By combining the data available from these tools, it's possible to build up a picture of the traffic hitting your application at any one time. A web application firewall (WAF) analyzes this data in real time to identify potential threats. Malicious actors can be blocked automatically, with machine learning applied to constantly improve the service.

Of course, all of these measures can be compromised if an attacker gains admin access to your API gateway. The Kong API Gateway provides a fully-secured, RBAC-controlled Admin API that can be additionally secured against unauthorized use with network layer access restrictions, specified IP ranges for access from outside the network and fine-grained access control by using Kong as a proxy to access its own API.

API Security and Gateway Best Practices

As well as the security measures discussed above, you can further improve the security of an API gateway by factoring this into the design phase. When building an API gateway, consider which endpoints need to be exposed and to whom.

Data Security

Many API gateways fall into the trap of exposing too much information and relying on the client to filter out any unnecessary data. Those extra details can be gold dust in the wrong hands, providing insight into your application architecture with verbose stack traces or even giving access to data that should not be available. Designing endpoints and error codes to meet the intended use cases but no more than that avoids too much information being exposed.

In a similar vein, the HTTP headers included in a response from a REST API can include information about the server and platform which can be used to exploit the system. By applying a transformation to a response at the API gateway, you can sanitize the outbound data to send only what is needed.

API Led Connectivity

If your application has multiple different use cases, such as mobile apps, IoT devices and integration with internal systems, consider creating separate API gateways for each one. This avoids exposing endpoints that are only intended for internal use, for example, to the wider world. To prevent unauthorized access, an API gateway for internal applications can be restricted to your organization's network or operate a whitelist of authorized clients.

Managing Deprecated APIs

Finally, it's essential to keep track of your APIs: ensure you remove any APIs that are no longer in use and deprecate old versions which do not include new security measures implemented at the application level. Managing your APIs through an API gateway gives you oversight of all your APIs and the ability to measure and analyze their usage.

Developer agility meets compliance and security. Discover how Kong can help you become an API-first company.

Get a DemoStart for Free
Topics:API Gateway
|
API Security
|
API Development
Powering the API world

Increase developer productivity, security, and performance at scale with the unified platform for API management, service mesh, and ingress controller.

Sign up for Kong newsletter

Platform
Kong KonnectKong GatewayKong AI GatewayKong InsomniaDeveloper PortalGateway ManagerCloud GatewayGet a Demo
Explore More
Open Banking API SolutionsAPI Governance SolutionsIstio API Gateway IntegrationKubernetes API ManagementAPI Gateway: Build vs BuyKong vs PostmanKong vs MuleSoftKong vs Apigee
Documentation
Kong Konnect DocsKong Gateway DocsKong Mesh DocsKong Insomnia DocsKong Plugin Hub
Open Source
Kong GatewayKumaInsomniaKong Community
Company
About KongCustomersCareersPressEventsContactPricing
  • Terms•
  • Privacy•
  • Trust and Compliance
  • © Kong Inc. 2025