Does readable data give permission to act?
05Follow an untrusted request through a reader, a strict writer and a separate permission gate.
The visitor asks to feed the cat. The note is untrusted data; reading it must not run it as a program.
An untrusted note, not a program
{"feed":"cat"}Visitor → app readerReading a note does not execute its words.
What happens if you change this?
Make one change, then watch again. Restart restores the original example.
Output uses quoted member names and valid separators, even if the input parser tolerated extensions.
Key idea: Read data with a parser, write it with a generator, and check permission separately before acting.
Terms
- JSON
- JavaScript Object Notation: shared rules for writing data as text. Apps in many languages use it.
- Object
- A group of named values, like drawers with different labels.
- Array
- A list whose values have meaningful positions.
- String
- A text value between quotation marks.
- Grammar
- Rules for which marks and words may appear and where.
- Interoperability
- Different apps can read the same data and agree about its meaning.
- Parser
- A reader that turns text into usable values.
- Generator
- A writer that turns usable values into correctly spelled JSON text.
- Nesting depth
- How many containers are inside other containers along the deepest branch.
Rules & examples
JSON is data; the app must decide what actions are allowed.
- A parser must accept conforming JSON texts, subject to the permitted implementation limits on size, depth, strings, and numbers.
- A parser may accept extensions, but generators must emit text that strictly conforms to JSON grammar.
- Do not use eval or an equivalent source-code execution mechanism to parse untrusted JSON.
Successful syntax parsing is separate from application schema validation, authorization, and safe use of values. Put practical input limits around untrusted data.
RFC 8259 §§9–10: parsers MUST accept conforming texts subject to permitted limits (size, depth, number range/precision and string contents/length); they MAY accept extensions. Generators MUST emit strict JSON. Our optional extension accepts only the one displayed final-comma fixture, not arbitrary relaxed syntax. The 3-level limit is chosen for this lesson. §12 warns against eval-like execution of input. Permission is a separate example application policy.
Sources
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.