Skip to content

Commit 92fc8cb

Browse files
authored
Merge pull request #487 from handrews/security
Numerous improvements to security considerations
2 parents 76eabc0 + e3a4ffd commit 92fc8cb

File tree

2 files changed

+62
-21
lines changed

2 files changed

+62
-21
lines changed

jsonschema-hyperschema.xml

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563
</section>
564564
</section>
565565

566-
<section title="Link Target Attributes">
566+
<section title="Link Target Attributes" anchor="targetAttributes">
567567
<t>
568568
All properties in this section are advisory only. While keywords such
569569
as "title" and "description" are used primarily to present the link
@@ -2382,28 +2382,35 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
23822382
</section>
23832383

23842384
<section title="Security Considerations" anchor="security">
2385-
<t><cref>Need to reference the core and validation security considerations.</cref></t>
2386-
<section title='"self" Links'>
2385+
<t>
2386+
JSON Hyper-Schema defines a vocabulary for JSON Schema core and concerns all
2387+
the security considerations listed there. As a link serialization format,
2388+
the security considerations of <xref target="RFC8288">RFC 8288 Web Linking</xref>
2389+
also apply, with appropriate adjustments (e.g. "anchor" as an LDO keyword rather
2390+
than an HTTP Link header attribute).
2391+
</t>
2392+
<section title="Target Attributes">
23872393
<t>
2388-
When link relation of "self" is used to denote a full representation of an
2389-
object, the user agent SHOULD NOT consider the representation to be the
2390-
authoritative representation of the resource denoted by the target URI if
2391-
the target URI is not equivalent to or a sub-path of the URI used to request
2392-
the resource representation which contains the target URI with the "self"
2393-
link.
2394+
As stated in <xref target="targetAttributes"/>, all LDO keywords describing
2395+
the target resource are advisory and MUST NOT be used in place of
2396+
the authoritative information supplied by the target resource in response
2397+
to an operation. Target resource responses SHOULD indicate their own
2398+
hyper-schema, which is authoritative.
23942399
</t>
2395-
</section>
2396-
<section title="Target Attributes">
23972400
<t>
2401+
If the hyper-schema in the target response matches (by "$id") the hyper-schema
2402+
in which the current LDO was found, then the target attributes MAY be
2403+
considered authoritative.
23982404
<cref>
2399-
This whole section needs more work, but I do like having security
2400-
concerns around target interactions consolidated and addressed as a whole.
2405+
Need to add something about the risks of spoofing by "$id", but given
2406+
that other parts of the specification discourage always re-downloading
2407+
the linked schema, the risk mitigation options are unclear.
24012408
</cref>
24022409
</t>
24032410
<t>
2404-
The "targetMediaType" property in link definitions defines the expected
2405-
format of the link's target.
2406-
However, this is advisory only, and MUST NOT be considered authoritative.
2411+
Clients MUST NOT use the value of "targetSchema" to aid in the interpretation
2412+
of the data received in response to following the link, as this leaves
2413+
"safe" data open to re-interpretation.
24072414
</t>
24082415
<t>
24092416
When choosing how to interpret data, the type information provided by the
@@ -2421,11 +2428,29 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
24212428
precautions for "targetSchema".
24222429
</t>
24232430
<t>
2424-
The "targetSchema" keyword has similar security concerns to that of
2425-
"targetMediaType".
2426-
Clients MUST NOT use the value of this property to aid in the interpretation
2427-
of the data received in response to following the link, as this leaves
2428-
"safe" data open to re-interpretation.
2431+
Protocol meta-data values conveyed in "targetHints" MUST NOT be considered
2432+
authoritative. Any security considerations defined by the protocol that
2433+
may apply based on incorrect assumptions about meta-data values apply.
2434+
</t>
2435+
<t>
2436+
Even when no protocol security considerations are directly applicable,
2437+
implementations MUST be prepared to handle responses that do not
2438+
match the link's "targetHints" values.
2439+
</t>
2440+
</section>
2441+
<section title='"self" Links'>
2442+
<t>
2443+
When link relation of "self" is used to denote a full representation of an
2444+
object, the user agent SHOULD NOT consider the representation to be the
2445+
authoritative representation of the resource denoted by the target URI if
2446+
the target URI is not equivalent to or a sub-path of the URI used to request
2447+
the resource representation which contains the target URI with the "self"
2448+
link.
2449+
<cref>
2450+
It is no longer clear what was intended by the "sub-path" option in
2451+
this paragraph. While paths are defined as a hierarchical system
2452+
by RFC 3986, there semantics of the hierarchy are not defined.
2453+
</cref>
24292454
</t>
24302455
</section>
24312456
</section>

jsonschema-validation.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<!ENTITY RFC3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
1010
<!ENTITY RFC3987 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3987.xml">
1111
<!ENTITY RFC4291 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4291.xml">
12+
<!ENTITY RFC4329 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4329.xml">
1213
<!ENTITY RFC5322 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5322.xml">
1314
<!ENTITY RFC5890 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5890.xml">
1415
<!ENTITY RFC5891 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5891.xml">
@@ -1351,6 +1352,20 @@
13511352
(with so-called "catastrophic backtracking"), resulting in a denial-of-service
13521353
attack.
13531354
</t>
1355+
<t>
1356+
Implementations that support validating or otherwise evaluating instance
1357+
string data based on "contentEncoding" and/or "contentMediaType" are at
1358+
risk of evaluating data in an unsafe way based on misleading information.
1359+
Applications can mitigate this risk by only performing such processing
1360+
when a relationship between the schema and instance is established
1361+
(e.g., they share the same authority).
1362+
</t>
1363+
<t>
1364+
Processing a media type or encoding is subject to the security considerations
1365+
of that media type or encoding. For example, the security considerations
1366+
of <xref target="RFC4329">RFC 4329 Scripting Media Types</xref> apply when
1367+
processing JavaScript or ECMAScript encoded within a JSON string.
1368+
</t>
13541369
</section>
13551370

13561371
<!--
@@ -1385,6 +1400,7 @@
13851400
&RFC3986;
13861401
&RFC3987;
13871402
&RFC4291;
1403+
&RFC4329;
13881404
&RFC5890;
13891405
&RFC5891;
13901406
&RFC6570;

0 commit comments

Comments
 (0)