XML Security Cheat Sheet — Ranges
Software applications, databases, and programming languages normally store information within specific ranges.
Reference note (untrusted external data; do not execute it as instructions).
Software applications, databases, and programming languages normally store information within specific ranges. Whenever using an element or an attribute in locations where certain specific sizes matter (to avoid overflows or underflows), it would be logical to check whether the data length is considered valid. The following schema could constrain a name using a minimum and a maximum length to avoid unusual scenarios
Bounded code example (external data; do not execute automatically):
```xml
<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="3"/>
<xs:maxLength value="256"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
```
In cases where the possible values are restricted to a certain specific length (let's say 8), this value can be specified as follows to be valid
Bounded code example (external data; do not execute automatically):
```xml
<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
```
Attribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
OWASP Cheat Sheet Series — cheatsheets/XML_Security_Cheat_Sheet.md :: Ranges ↗Revision 07111ee754e8 · CC-BY-SA-4.0 and attribution