<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xsl" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc toc="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc symrefs="yes" ?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" ipr="trust200902"
  submissionType="IETF" docName="draft-ietf-mediaman-suffixes-04"
  tocInclude="true" sortRefs="true" symRefs="true" version="2">

<front>

  <title>Media Types with Multiple Suffixes</title>
  <seriesInfo name="Internet-Draft" value="draft-ietf-mediaman-suffixes-04"/>
  <author initials="M." surname="Sporny" fullname="Manu Sporny">
    <organization>Digital Bazaar</organization>
    <address>
      <postal>
        <street>203 Roanoke Street W.</street>
        <city>Blacksburg</city>
        <region>VA</region>
        <code>24060</code>
        <country>US</country>
      </postal>
      <email>msporny@digitalbazaar.com</email>
      <uri>http://manu.sporny.org/</uri>
    </address>
  </author>

  <author initials="A." surname="Guy" fullname="Amy Guy">
    <organization>Digital Bazaar</organization>
    <address>
      <postal>
        <street>203 Roanoke Street W.</street>
        <city>Blacksburg</city>
        <region>VA</region>
        <code>24060</code>
        <country>US</country>
      </postal>
      <email>rhiaro@digitalbazaar.com</email>
      <uri>https://rhiaro.co.uk/</uri>
    </address>
  </author>

  <date month="June" day="16" year="2023" />
  <area>Internet</area>
  <workgroup>MEDIAMAN</workgroup>

  <abstract>
    <t>
This document updates RFC 6838 "Media Type Specifications and Registration
Procedures" to describe how to interpret subtypes with multiple suffixes.
    </t>
  </abstract>

</front>
<middle>
  <section anchor="intro">
    <name>Introduction</name>
    <t>
As written, RFC 6838 [RFC6838] permits the registration of media type subtype
names which contain any number of occurrences of the "+" character. RFC 6838
defines the characters following the final "+" to be a structured syntax
suffix, but does not define anything further about how to interpret subtype
names containing more than one "+" character.
    </t>
    <t>
This document updates RFC 6838 to clarify how to interpret subtype names
containing more than one "+" character as subtypes with multiple suffixes.
    </t>
    <t>
As registration of media types which use a structured suffix has become widely
supported, this enables further specialization of media types that build on
already registered and well-defined media types which themselves use a
structured suffix.
    </t>

    <section anchor="conventions">
      <name>Conventions Used in This Document</name>
      <t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when,
and only when, they appear in all capitals, as shown here.
      </t>
    </section>
  </section>

  <section anchor="media-types-with-multiple-suffixes">
    <name>Media Types with Multiple Suffixes</name>
    <t>
The following paragraphs are additions to RFC 6838.
    </t>
    <t>
Media types MAY be registered with more than one suffix appended to the base
subtype name. The suffixes MUST be interpreted as ordered. Valid media type
names containing a structured suffix are built from right to left (not left
to right). Characters on the left-most side of the left-most "+" in a subtype
name specify the base subtype name. Characters to the right of each "+" in
a subtype name denote additional structured syntax suffixes.
    </t>
    <t>
Media types with more than one suffix MUST be registered according to the
procedure defined in [RFC6838]. A new base subtype name MUST only be
registered with suffix combinations that are already registered in their own
right in the
<eref target="https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml">Structured Syntax Suffixes registry</eref>.
    </t>
    <t>
For example, a media type that uses two suffixes, such as
"application/foo+bar+baz" is only permitted insofar as "+baz" and "+bar+baz"
are already registered structured syntax suffixes.
    </t>

    <section anchor="processing">
      <name>Processing Multiple Suffixes</name>
      <t>
Registered media types have clear processing rules. In cases where specific
handling of the exact media type is not required, receivers of the media type
MAY do generic processing on the underlying representation
according to their ability to process any subset of the suffix(es) from right
to left inclusive. In other words, an application can choose to ignore the
base subtype name from a media type with multiple suffixes, and process
according to the remaining media type suffix(es).
      </t>
      <t>
This sort of generic processing of a portion of the media type MAY be utilized
by a processor that is capable of applying decoding rules associated with the
portion of the structured syntax suffix in the
<eref target="https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml">Structured Syntax Suffixes Registry</eref>.
      </t>
      <t>
For example, for the media type "application/did+ld+json", applications can
choose to process the underlying representation according to any of the
following processing models:
      </t>
      <ol>
        <li> application/did+ld+json (as specified in the  <eref target="https://www.iana.org/assignments/media-types/media-types.xhtml">Media Type Registry</eref>),</li>
        <li> +ld+json (as specified in the <eref target="https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml">Structured Syntax Suffixes Registry</eref>),</li>
        <li> +json (as specified in the <eref target="https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml">Structured Syntax Suffixes Registry</eref>).</li>
      </ol>
      <t>
If an application choses to utilize a portion of the media type that is a
structured syntax suffix, the suffix MUST exist as an entry in the
<eref target="https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml">
Structured Syntax Suffixes Registry</eref>
and the specification referred to in the "Encoding Considerations"
entry of the registry MUST be used for both encoding and decoding the byte
stream associated with the media type.
      </t>
    </section>

    <section anchor="fragments">
      <name>Fragment Identifiers</name>
      <t>
The syntax and semantics for fragment identifiers are specified in the
"Fragment Identifier Considerations" column in the IANA Structured Syntax
Suffixes registry. In general, when processing fragment identifiers associated
with a structured syntax suffix, the following rules SHOULD be followed:
      </t>
      <ol>
        <li>
For cases defined for the structured syntax suffix, where the fragment
identifier does resolve per the structured syntax suffix rules, then as
specified by the specification associated with the "Fragment Identifier
Considerations" column in the IANA Structured Syntax Suffixes registry.
        </li>
        <li>
For cases defined for the structured syntax suffix, where the fragment
identifier does not resolve per the structured syntax suffix rules, then as
specified by the specification associated with the full media type.
        </li>
        <li>
For cases not defined for the structured syntax suffix, then as specified by the
specification associated with the full media type.
        </li>
      </ol>
      <t>
Other advisory information, such as fragment processing not being defined in any
existing specification, MAY be provided in the "Fragment Identifier
Considerations" column in the IANA Structured Syntax Suffixes registry as long
as the text is terse in nature.
      </t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <section anchor="media-type-fibbing">
        <name>Media Type Fibbing</name>
        <t>
It is possible for an attacker to utilize multiple structured suffixes in a way
that tricks unsuspecting toolchains into skipping important security checks
and allowing viruses to propagate. For example, an attacker might utilize an
"application/vnd.ms-excel.addin.macroEnabled.12+zip" structured suffix to
trigger an unzip process that would then invoke Microsoft Excel directly,
bypassing anti-virus tooling that would otherwise block a macro-enabled MS
Excel file containing a virus of some kind from being scanned or opened.
        </t>
        <t>
While the liklihood of these sorts of attacks are low, they are not zero and
enterprising attackers might take advantage of applications that carelessly
process media types in this manner. These sorts of toolchains need to ensure
that the incoming media type is not blindly trusted and that proper magic header
or file structure checking is performed before allowing the encoded data to
drive operations that might negatively impact the application environment or
operating system.
        </t>
      </section>
    </section>
  </section>

</middle>

<back>
  <references>
    <name>Normative References</name>
    <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
      <front>
        <title>Key words for use in RFCs to Indicate Requirement Levels</title>
        <author initials="S." surname="Bradner" fullname="S. Bradner">
          <organization />
        </author>
        <date year="1997" month="March" />
      </front>
      <seriesInfo name="BCP" value="14" />
      <seriesInfo name="RFC" value="2119" />
      <seriesInfo name="DOI" value="10.17487/RFC2119" />
    </reference>
    <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
      <front>
        <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
        <author initials="B." surname="Leiba" fullname="B. Leiba">
          <organization />
        </author>
        <date year="2017" month="May" />
      </front>
      <seriesInfo name="BCP" value="14" />
      <seriesInfo name="RFC" value="8174" />
      <seriesInfo name="DOI" value="10.17487/RFC8174" />
    </reference>
    <reference anchor="RFC6838" target="https://www.rfc-editor.org/info/rfc6838">
      <front>
        <title>Media Type Specifications and Registration Procedures</title>
        <author initials="N." surname="Freed" fullname="N. Freed">
          <organization />
        </author>
        <author initials="J." surname="Klensin" fullname="J. Klensin">
          <organization />
        </author>
        <author initials="T." surname="Hansen" fullname="T. Hansen">
          <organization />
        </author>
        <date year="2013" month="January" />
      </front>
      <seriesInfo name="BCP" value="13" />
      <seriesInfo name="RFC" value="6838" />
      <seriesInfo name="DOI" value="10.17487/RFC6838" />
    </reference>
  </references>

  <section anchor="acknowledgements">
    <name>Acknowledgements</name>
    <t>
The editors would like to thank the following individuals for feedback on the
specification (in alphabetical order): Harald Alvestrand, Martin J. Dürst,
Ivan Herman, Graham Klyne, Murray S. Kucherawy, Mark Nottingham,
Roberto Polli, Orie Steele, and Ted Thibodeau Jr.
    </t>
  </section>

</back>
</rfc>
