Application Security Best Practices: 15 Controls for Web Apps and APIs

Application Security Best Practices

Table of Contents

Share Article

Key Takeaways
Application security best practices are the controls that protect an application at every stage, from design and coding to deployment and runtime. This application security checklist groups 15 of them for web apps and APIs: a secure SDLC, threat modeling, safe coding, strong identity, automated testing and runtime protection through a WAAP [Web Application and API Protection].

Why These Controls Matter: Recent API Security Incidents

These controls address real weaknesses highlighted by 2026 incidents across healthcare, developer platforms, and AI research.

Third-party access to healthcare APIs

In September 2026, Veradigm disclosed in an SEC filing that an unauthorized party used credentials obtained from a third-party vendor to access a customer-service API and download patients’ personal information, including Social Security numbers in some cases. The incident highlights the importance of securing vendor access, restricting API permissions, and monitoring data downloads.

Exposed API keys in developer tooling

In October 2026, OpenCode disclosed a security breach on its official X account that affected 1.4% of OpenCode Console users. Third-party AI provider API keys stored in Console may have been exposed, and some users reported unauthorized usage charges. The incident shows why stored secrets need strong access controls, rapid revocation procedures, and usage monitoring.

An exposed research environment

In August 2026, METR published its security update describing an earlier incident in which a publicly accessible research instance had a fail-open authentication flaw that exposed an API key. An attacker obtained the key and used it over three weeks to consume AI credits worth approximately $600,000. METR also described a separate incident involving an inadvertently exposed endpoint. These cases illustrate the risks of weak authentication, exposed credentials, and inadequate usage monitoring.
The lesson is consistent: attackers can exploit poorly protected integrations, exposed secrets, and weak authentication without needing a novel API exploit. Controls 7, 12, and 15 below address these risks through stronger access restrictions, credential protection, and continuous monitoring.

Design: Secure SDLC and Threat Modeling

1. Make security a design requirement

Treat security as a design requirement, not a post-hoc review item. A secure SDLC places checks in every phase: requirements, design, build, test, release and operation. Write security acceptance criteria into each user story so a feature cannot ship without them.

2. Run threat modeling early

Identify assets, data flows and trust boundaries during planning, so attacks such as SQL injection and cross-site scripting are anticipated before code exists. Revisit the model whenever you add a third-party integration or a new API, because that is where trust boundaries shift.

3. Apply least privilege

Give users, services and containers only the permissions their tasks need. Review service accounts and API tokens on a schedule, and remove access that has not been used.

Code: Web Application Security Best Practices

4. Validate input server-side

Check forms, APIs and file uploads against strict allowlists, not blocklists. Client-side checks improve usability but never count as a control.

5. Use parameterized queries

Prepared statements or an ORM keep user input as data, not executable code.

6. Encode output by context

Encode data for HTML, JavaScript or URLs before rendering it, to mitigate cross-site scripting.

7. Keep secrets out of code

Never embed passwords or API keys in source code or configuration files. Use environment variables or a secrets vault, and scan repositories and shared workspaces for leaked keys, since exposed credentials are a recurring cause of API breaches.

Identity and Data Protection

8. Enforce MFA and standard protocols

Require multi-factor authentication, especially for admin accounts, and prefer OAuth 2.0 and OpenID Connect over custom logins. See OAuth API security.

9. Authorize on the server, deny by default

Check role-based or custom privileges on every request, including object-level checks so one user cannot read another user’s records by changing an ID.

10. Encrypt in transit and at rest

Enforce HTTPS/TLS and encrypt sensitive stored data.

11. Harden sessions

Set Secure, HttpOnly and SameSite flags on session cookies to limit interception and cross-site request forgery. Expire sessions on logout and after inactivity.

API Security Best Practices

12. Discover, limit and validate

Catalog every API to eliminate shadow endpoints, apply rate limits and validate JSON Web Tokens.
API documentation is frequently out of date, so discovery should come from live traffic. Check Point’s paper reports a 400% increase in API attacks in the first half of 2023. Check Point cites a Gartner prediction that fewer than 50% of enterprise APIs would be appropriately managed by 2025. See real-time API discovery.

Pipeline: SAST and DAST

13. Automate testing in CI/CD

SAST analyzes source code, DAST tests the running application and software composition analysis (SCA) checks third-party components. It’s best to build automated security testing into CI/CD pipelines. Fail the build on high-severity findings so issues are fixed while the code is fresh. See CI/CD pipeline security.

14. Patch dependencies

Track vulnerabilities in third-party libraries and remove unused packages. Keep a software bill of materials so you can answer “are we affected?” within hours of a new disclosure.

Runtime: Web Application Firewall, Virtual Patching and Bot Protection

15. Put a protective layer in front

Harvard’s application security guidance recommends exposing only necessary services and placing web applications behind reverse proxies or application gateways.

Checklist at a glance

Use the OWASP Top 10 as Your Test Plan

OWASP describes its Top 10 as a standard awareness document that reflects broad consensus on the most critical web application risks. Map each control above to a risk, then test for it. For APIs, use the OWASP API Security Top 10. Prophaze’s brief maps all ten 2023 categories to enforcement, for example autonomous discovery for API9:2023 Improper Inventory Management and behavioral monitoring for API1:2023 Broken Object Level Authorization.

Where Prophaze Fits: API Security and Discovery for Web Apps

Controls 12 and 15 are where most teams struggle, because code review and scanners only see what is already known. That gap is exactly what we built Prophaze WAAP to close. It sits in front of your web applications and APIs, learns from live traffic and enforces policy at the edge. It complements secure coding, testing and patching; it does not replace them. If you are weighing the two approaches, our guide to WAAP vs WAF explains the difference.

See every API first

Prophaze builds your API picture from live traffic, so shadow and undocumented endpoints appear even when nobody wrote them down. You cannot protect what you cannot see, so we treat discovery as step one and policy as step two.

Protect each API for what it is

A GraphQL endpoint and a REST endpoint fail in different ways. With API Type Configuration you declare an application as REST, GraphQL or both, and protections follow, which sharpens detection and cuts false positives. API rules now live in their own built-in WAF policies interface, so they no longer share a screen with generic web rules.

Watch what leaves, not only what arrives

Many API breaches are data exposure: a perfectly valid request returns more than it should. Prophaze can enforce policy on API responses as well as incoming requests, and schema validation with response filtering helps keep privileged object data from leaking. Behavioral analysis with real-time risk scoring flags unusual object access patterns, an early sign of broken object-level authorization abuse.

Buy time with virtual patching

When a flaw is disclosed and the fix is a sprint away, we block exploitation at the edge without touching application code. Controls for business logic and sensitive data go beyond signatures to catch abuse of legitimate workflows.

Investigate in minutes, not hours

When a request is blocked, Attack Analytics shows the payload in a formatted JSON viewer with the matching pattern highlighted. The upstream_status field in WAAP traffic logs tells you whether the WAAP or the application stopped it. You can also switch anomaly detection on or off per application, so tuning one app never affects another.
A practical order of work is to start with API discovery, tune security policies for each API type, and apply stronger response controls to endpoints that return sensitive data. Explore our API security solution and API gateway security to learn how these controls help protect your APIs.
Want to explore the capabilities in more detail? [Explore our API Security Datasheet] to learn how we help in discovering exposed APIs, identify security risks, and strengthen API protection.
Get a clearer view of your API attack surface, uncover security gaps, and understand where additional protection may be needed. Connect with us to explore how our API security capabilities can help you monitor API activity and protect sensitive data.

Frequently Asked Questions (FAQ)

1. What are the best practices for application security?
Build security into every phase: threat model during design, validate input and use parameterized queries in code, enforce strong authentication and server-side authorization, automate SAST, DAST and SCA in CI/CD, patch dependencies, and add runtime protection such as a WAF or WAAP.
SAST analyzes source code without running it, so it catches flaws early. DAST tests the running application from the outside, so it finds issues that appear only at runtime. Most pipelines use both.
WAAP (Web Application and API Protection) is the term Gartner uses for the next stage of WAF. A traditional WAF focuses mainly on rule-based protection for web pages. A WAAP adds API discovery and protection, bot management and deeper behavioral analysis.
Virtual patching blocks exploitation of a known flaw at the WAAP layer without changing application code. It buys time between a vulnerability’s disclosure and the permanent fix.
Because they sit outside testing, patching and monitoring. Scanners and reviews cover known assets, so an undocumented endpoint stays exposed until live-traffic discovery finds it.

You May Also Like

Indonesia Bank Cyberattack

Indonesia Bank Cyberattack: What OJK Told Banks to Do

Attempts against Indonesia’s financial sector passed 1.2 million in 24 hours. No bank has confirmed

AI Security Risk Assessment

AI Security Risk Assessment: How to Measure AI Risk Across the Enterprise

Key Takeaways Most enterprises cannot see all their AI. HiddenLayer’s 2026 AI Threat Landscape Report

Weekly Threat Report November 5–11, 2026

Weekly Threat Report, November 5–11, 2026: AI Secret Exposure, OpenSSH Bypass and Refrigeration Sabotage Follow-Up

Key Takeaways Secrets in agent settings and cloud environments create persistent exposure beyond the original

Scroll to Top