Skip to content

Commit 62f00ae

Browse files
Matt WilliamsMatt Williams
authored andcommitted
Fix: Apply sentence casing to all headings per reviewer feedback
- Changed all headings from title case to sentence case - Addresses @adamaltman review comment on PR #109
1 parent 3a9e8f9 commit 62f00ae

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

learn/security/api-input-validation-injection-prevention.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ seo:
1010

1111
---
1212

13-
## Key Takeaways
13+
## Key takeaways
1414

1515
APIs are designed to accept data as input. However, an API should never blindly trust the data it receives from a client. The process of rigorously checking all incoming data is called data validation.
1616

@@ -24,7 +24,7 @@ APIs are designed to accept data as input. However, an API should never blindly
2424

2525
---
2626

27-
## Quick Start Guide
27+
## Quick start guide
2828

2929
Ready to implement secure input validation? Follow these steps:
3030

@@ -38,11 +38,11 @@ Ready to implement secure input validation? Follow these steps:
3838

3939
---
4040

41-
## The Restaurant Waiter Principle
41+
## The restaurant waiter principle
4242

4343
> **The Restaurant Waiter**: The API is the waiter, and its documentation (or schema) is the menu. The menu explicitly states what can be ordered and in what format (e.g., "Steak - medium rare"). If a customer tries to order something not on the menu, like "a bicycle," or provides an invalid option, like "a million steaks," a competent waiter will immediately reject the order at the table before it ever reaches the kitchen. This is data validation.
4444
45-
## Technical Implementation of Data Validation
45+
## Technical implementation of data validation
4646

4747
In technical terms, data validation is the practice of checking all incoming data from a client to ensure it conforms to the expected format, type, range, and other constraints before it is processed by the application's business logic.
4848

@@ -52,14 +52,14 @@ Proper data validation is a critical defense against a wide range of attacks, no
5252

5353
If the API fails to validate the input and passes it directly to a database or the operating system, that malicious code could be executed. By strictly validating that all inputs are what they are supposed to be, an API can reject malicious payloads before they can do any harm.
5454

55-
## Attack Prevention Strategies
55+
## Attack prevention strategies
5656

5757
Choose the appropriate prevention strategy based on the attack vector you're protecting against:
5858

5959
{% tabs %}
6060
{% tab label="SQL Injection Prevention" %}
6161

62-
### SQL Injection Prevention
62+
### SQL injection prevention
6363

6464
For interactions with a database, the gold standard for preventing SQL injection attacks is the use of parameterized queries, also known as prepared statements.
6565

@@ -109,7 +109,7 @@ app.get('/users/:id', async (req, res) => {
109109
{% /tab %}
110110
{% tab label="Mass Assignment Prevention" %}
111111

112-
### Mass Assignment Attack Prevention
112+
### Mass assignment attack prevention
113113

114114
Mass assignment attacks occur when an application accepts more input parameters than expected, allowing attackers to modify fields they shouldn't have access to. The `additionalProperties: false` constraint is essential for preventing these attacks.
115115

@@ -164,7 +164,7 @@ NewUser:
164164
{% /tab %}
165165
{% /tabs %}
166166

167-
## Schema-Based Validation as Security Contract
167+
## Schema-based validation as security contract
168168

169169
OpenAPI 3.1 provides a comprehensive vocabulary for defining strict validation rules by leveraging JSON Schema Draft 2020-12. By codifying these rules directly in your API specification, validation becomes core to your API's design.
170170

@@ -296,15 +296,15 @@ ValidationPattern:
296296
- **Pattern validation** blocks injection attempts and malformed data
297297
- **Enum restrictions** enforce allow-lists instead of dangerous validation bypass
298298

299-
### Automated Governance for Validation
299+
### Automated governance for validation
300300

301301
Modern API governance tools can enforce input validation rules that require string length bounds, numeric ranges, and prevent mass assignment vulnerabilities.
302302

303303
This governance approach transforms security reviews. Instead of manually checking many properties for missing `maxLength` constraints, automated linting tools handle baseline validation so security teams can focus on strategic concerns like business logic and context-dependent risks.
304304

305305
> **🚀 Interactive Implementation**: Learn to set up comprehensive input validation with our [Automated Security Validation Walkthrough](automated-security-validation-walkthrough), which includes production-ready rules for OWASP API Security Top 10 2023 compliance.
306306

307-
## Key Security Constraints
307+
## Key security constraints
308308

309309
The most critical schema constraints for API security focus on preventing resource exhaustion and injection attacks:
310310

@@ -315,7 +315,7 @@ The most critical schema constraints for API security focus on preventing resour
315315

316316
These constraints can be automatically enforced by governance rules, ensuring no schema can bypass these fundamental protections.
317317

318-
## Common Validation Patterns
318+
## Common validation patterns
319319

320320
{% table %}
321321
* Input Type
@@ -373,7 +373,7 @@ properties:
373373

374374
> API Security Best Practice: "Blocking PRs that add new string fields without `maxLength` constraints is one of the most cost-effective security guardrails you can implement."
375375

376-
## Attack Example: Equifax (OGNL injection via Apache Struts, 2017)
376+
## Attack example: Equifax (OGNL injection via Apache Struts, 2017)
377377

378378
The 2017 Equifax data breach was the result of a catastrophic input validation failure in the Apache Struts framework (CVE-2017-5638). The vulnerability allowed attackers to perform remote code execution by sending a specially crafted `Content-Type` header. The Struts framework failed to properly sanitize this header value, interpreting it as an Object-Graph Navigation Language (OGNL) expression and executing it. This gave attackers a direct shell on the server, which they used to access sensitive databases and exfiltrate the personal data of over 140 million people.
379379

@@ -400,14 +400,14 @@ Why this matters: Strong schema validation, input allow-lists, and patch hygiene
400400

401401
**Security operations:** When schema validation and [attack prevention strategies](#attack-prevention-strategies) are in place, implement [monitoring](#input-validation-monitoring) to detect attempted breaches and [advanced validation techniques](#advanced-validation-techniques) for complex scenarios.
402402

403-
## Input Validation Monitoring
403+
## Input validation monitoring
404404

405405
Choose your monitoring approach based on your security operations needs:
406406

407407
{% tabs %}
408408
{% tab label="Validation Logging (JavaScript)" %}
409409

410-
### Validation Failure Logging
410+
### Validation failure logging
411411

412412
**Express.js Middleware for Security Monitoring**
413413

@@ -445,7 +445,7 @@ app.use((req, res, next) => {
445445
{% /tab %}
446446
{% tab label="Validation Metrics (JavaScript)" %}
447447

448-
### Validation Metrics
448+
### Validation metrics
449449

450450
```javascript
451451
// Track validation patterns for security analysis
@@ -520,9 +520,9 @@ function trackValidationError(req, field, errorType) {
520520
{% /tab %}
521521
{% /tabs %}
522522

523-
## Advanced Validation Techniques
523+
## Advanced validation techniques
524524

525-
### Custom Format Validators
525+
### Custom format validators
526526
```javascript
527527
// Custom OpenAPI format validators
528528
const customFormats = {
@@ -553,7 +553,7 @@ const schema = {
553553
};
554554
```
555555

556-
### Contextual Validation Rules
556+
### Contextual validation rules
557557
```yaml {% title="openapi.yaml" %}
558558
# Different validation rules based on context
559559
components:
@@ -577,7 +577,7 @@ components:
577577
pattern: "^[\\w\\s._@-]+$" # Less restrictive for internal use
578578
```
579579
580-
## Frequently Asked Questions
580+
## Frequently asked questions
581581
582582
### How does OpenAPI validation prevent injection attacks?
583583
OpenAPI specifications define precise data schemas with type validation, format constraints, and length limits. When enforced by [automated governance](#automated-governance-for-validation), these schemas automatically reject malformed inputs that could contain injection payloads, stopping attacks before they reach your application logic. See [Schema-Based Validation as Security Contract](#schema-based-validation-as-security-contract) for implementation details.
@@ -594,7 +594,7 @@ File uploads require special attention: validate file types using content inspec
594594
### What's the performance impact of extensive validation?
595595
Modern validation libraries are highly optimized. The security benefit far outweighs the minimal performance cost. Consider caching compiled schemas and using efficient validation libraries like `ajv` for JavaScript or `jsonschema` for Python. Implement [validation monitoring](#input-validation-monitoring) to track performance impacts.
596596

597-
## Resources and Next Steps
597+
## Resources and next steps
598598

599599
### Essential Reading
600600
- [OWASP API Security Top 10](https://owasp.org/www-project-api-security/) - Comprehensive vulnerability guide including injection attacks (API3:2023) and resource consumption (API4:2023)

0 commit comments

Comments
 (0)