Repository navigation
String has no format/pattern/enum #219
Description
Problem description
code/API_definitions/webrtc-call-handling.yaml:464:14 (hdrRegistrationId) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-call-handling.yaml:474:14 (pathParamMediaSessionId) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-call-handling.yaml:496:24 (MediaSessionInformation) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-call-handling.yaml:503:22 (MediaSessionInformation) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-call-handling.yaml:550:28 (MediaSessionResponse) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-call-handling.yaml:583:13 (WrtcSdpDescriptor) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:838:20 (RegistrationId) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:850:18 (WebrtcEventNotification) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:922:24 (MediaSession) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:933:22 (MediaSession) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:964:24 (MediaSession) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:969:16 (MediaSession) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:1008:13 (WrtcSdpDescriptor) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-events-subscriptions.yaml:1082:32 (RegistrationEnds) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-registration.yaml:467:14 (pathParamRegistrationId) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
code/API_definitions/webrtc-registration.yaml:557:24 (RegSessionResponse) — [S-313] Schema of type string should specify a format, pattern, enum, or const.
Expected behavior
Review use of format, pattern, enum, or const in each schema
Activity
stroncoso commentedon Sep 21, 2026
Taking a deep look to get a complete table and potential patterns to use and share with the team...
stroncoso commentedon Oct 6, 2026
S-313 string constraints (issue #219)
"alice" <a@x.id>is allowed right now...@teikuran , @deepakjaiswal1 , take a look, or we can discuss it on the WebRTC meeting session.
Thanks in advance!
Rule S-313 (
owasp:api4:2023-string-restricted): Schema of type string should specify a format, pattern, enum, or const.All affected strings already satisfy S-312 (
maxLength). The proposal below adds apatternorenumto each one, as a base security limit against injection.Affected strings
registrationIdhdrRegistrationId:464 (header)registration
pathParamRegistrationId:467 (path)registration
RegSessionResponse.registrationId:557events
RegistrationId:838maxLength: 256ln3C-ttOSk-ObcQ7A0-tYO1LXqyxsmcaum3z4zw4l0cu4w115m0a1b2c3d4-1234-5678-abcd-ef0123456789^[A-Za-z0-9._~-]{1,256}$Define once as shared
RegistrationIdschema and$refit from all 4 places.mediaSessionIdpathParamMediaSessionId:474 (path)call-handling
MediaSessionResponse.mediaSessionId:550events
MediaSession.mediaSessionId:964maxLength: 2560AEE1B58BAEEDA3EABA42B32EBB3DFE07E9CFF402EAF9EED8EF^[A-Za-z0-9._~-]{1,256}$Define once as shared
MediaSessionIdschema and$refit from all 3 places.originatorNameMediaSessionInformation:496events
MediaSession:922maxLength: 256Alice^[^\x00-\x1F\x7F-\x9F---]{1,256}$See Display names: symbols and URI-like content.
receiverNameMediaSessionInformation:503events
MediaSession:933maxLength: 256BobsdpWrtcSdpDescriptor.sdp:583events
WrtcSdpDescriptor.sdp:1008maxLength: 65536v=0\r\no=- 4576312012535546667 4 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n...<type>=<value>lines):^v=0(\r?\n[a-z]=[^\r\n]*)*\r?\n?$Requires fixing the truncated examples (
[...]) in call-handling and events.type(CloudEvent)CloudEvent.type:850maxLength: 512org.camaraproject.webrtc-events-subscriptions.v0.session-invitation...v0.session-invitation...v0.session-status...v0.subscription-ended...v0.registration-endsreasonMediaSession.reason:969maxLength: 2048New subscriber incoming call^[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]{1,2048}$terminationDescriptionRegistrationEnds.terminationDescription:1083maxLength: 2048SIP re-registration requiredPattern behaviour examples
Results verified with the ECMA-262 regex engine (the one used by OpenAPI/JSON Schema validators).
^[A-Za-z0-9._~-]{1,256}$^[^\x00-\x1F\x7F-\x9F---]{1,256}$^[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]{1,2048}$^v=0(\r?\n[a-z]=[^\r\n]*)*\r?\n?$ln3C-ttOSk-ObcQ7A0-tYO1LXqya1b2c3d4-1234-5678-abcd-ef0123456789abc/../xid;DROP TABLEid%0d%0aAliceJosé ÑúñezO'Brien王小明Dr. Alice (Sales)Alice & BobBob 📞Alice\r\nX-Injected: 1Bob\x00Alice\x1B[31mBobgpj.exeBobexe.jpg)AliceAlice)<script>alert(1)</script>"Alice" <sip:evil@x.com>sip:evil@x.comv=0\r\no=- 1 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\nv=0\r\na=mid:audio\r\n [...]v=0\r\nINVITE sip:x SIP/2.0\r\nDisplay names: symbols and URI-like content
Open point: should
originatorName/receiverNameaccept symbols and URI-like content such as"Alice" <sip:evil@x.com>?These values may end up as the display name in SIP
From/Toheaders and in caller UIs. Accepting",<and>allows a name that imitates a full SIP name-addr, which can spoof the caller identity shown to the user or break header quoting if the gateway does not escape it.Alice & Bob<script>…"Alice" <sip:evil@x.com>sip:evil@x.com^[^\x00-\x1F\x7F]{1,256}$^[^\x00-\x1F\x7F-\x9F---]{1,256}$"<>^[^\x00-\x1F\x7F-\x9F---"<>]{1,256}$:or@would also reject legitimate names.^[\p{L}\p{M}\p{N} .,'()\-]{1,256}$&, emoji and other symbols. Needs the regexuflag, which OpenAPI tools support inconsistently.Whatever the option, the field description should state that implementations MUST escape the value for its output context (SIP header quoting, HTML), since no pattern replaces output encoding.
teikuran commentedon Oct 7, 2026
@stroncoso
According to Section 2.2 of the CAMARA API Design Guide, "If the data type is string, maxLength property or enum construct MUST be used to constrain values." It also states, "If the data type is string it is RECOMMENDED to use the appropriate modifier property format and/or pattern whenever possible."
My understanding is therefore that maxLength (or enum) is the mandatory requirement, while adding format and/or pattern is recommended where an appropriate constraint can be defined.
For the S-313 findings where maxLength is already specified, it seems that the mandatory requirement in Section 2.2 is already satisfied. Therefore, I am not sure that we need to introduce a pattern simply to clear every S-313 warning. I am not saying that we do not need to study those findinds - but are they urgent for this release?
rartych commentedon Oct 7, 2026