Pcornel
Networking · Security › REST API Security

REST API Input Validation

Cheat sheet · https://pcornel.dk/topic.php?topic=1553

Back to the Topic

Answer

Input validation constrains request types, lengths, ranges, media types and data models before acting on untrusted input.

Remember

A schema-valid payload is not proof of authorized intent or safe network behavior; rejected malformed input does not prove every parser path is safe.

First checks

In a lab, send a request with a wrong type, an out-of-range value and an unknown field → expect 400 or 422 with an error body, and no change made. With RESTCONF, the YANG model performs this validation for you.

Verify in this order

request arrives → size and content type checked → body parsed against the schema or YANG model → values range-checked → rejected with 400/422 before anything is done → accepted input passed on as parameters, never pasted into commands or queries

Where it usually breaks

physical/link dependency → local object state → peer/control state → policy → forwarding/adjacency → end-to-end result

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=1553

Confirmation

Confirm action

Continue?