<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "../Tools/rfcbootstrap/rfc2629-xhtml.ent">

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-nottingham-how-did-that-get-into-the-repo-02" number="0000" obsoletes="" updates="" submissionType="IETF" category="info" consensus="true" xml:lang="en" tocInclude="true" sortRefs="true" symRefs="true" version="3">

  <!-- xml2rfc v2v3 conversion 3.2.1 -->
  <front>
    <title>The secret-token URI Scheme</title>
    <seriesInfo name="RFC" value="0000"/>
    <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
      <organization/>
      <address>
        <postal>
          <city>Prahran</city>
          <region>VIC</region>
          <country>Australia</country>
        </postal>
        <email>mnot@mnot.net</email>
        <uri>https://www.mnot.net/</uri>
      </address>
    </author>
    <date year="2020" month="October" />
    <area>General</area>

<!-- [rfced] Please insert any keywords (beyond those that appear in the title) for use on https://www.rfc-editor.org/search. -->

<keyword>example</keyword>

    <abstract>
      <t>This document registers the "secret-token" URI scheme, to aid in the identification
of authentication tokens.</t>
    </abstract>
    <note>
      <name>Note to Readers</name>
      <t><em>RFC EDITOR: please remove this section before publication</em></t>
      <t>The issues list for this draft can be found at <eref target="https://github.com/mnot/I-D/labels/how-did-that-get-into-the-repo">https://github.com/mnot/I-D/labels/how-did-that-get-into-the-repo</eref>.</t>
      <t>The most recent (often, unpublished) draft is at <eref target="https://mnot.github.io/I-D/how-did-that-get-into-the-repo/">https://mnot.github.io/I-D/how-did-that-get-into-the-repo/</eref>.</t>
      <t>Recent changes are listed at <eref target="https://github.com/mnot/I-D/commits/gh-pages/how-did-that-get-into-the-repo">https://github.com/mnot/I-D/commits/gh-pages/how-did-that-get-into-the-repo</eref>.</t>
      <t>See also the draft's current status in the IETF datatracker, at
<eref target="https://datatracker.ietf.org/doc/draft-nottingham-how-did-that-get-into-the-repo/">https://datatracker.ietf.org/doc/draft-nottingham-how-did-that-get-into-the-repo/</eref>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>It has become increasingly common to use bearer tokens as an authentication mechanism in various
protocols.</t>
      <t>A bearer token is a security token with the property that any party in possession of the token (a
"bearer") can use the token in any way that any other party in possession of it can. Using a bearer
token does not require a bearer to prove possession of cryptographic key material
(proof-of-possession).</t>
      <t>Unfortunately, the number of security incidents involving accidental disclosure of these tokens has also increased. For example, we now regularly hear about a developer committing an access token to a public source code repository, either because they didn't realise it was included in the committed code, or because they didn't realise the implications of its disclosure.</t>
      <t>This specification registers the "secret-token" URI scheme to aid prevention of such accidental disclosures. When tokens are easier to unambiguously identify, they can trigger warnings in Continuous Integration systems, or be used in source code repositories themselves. They can also be scanned for separately.</t>
      <t>For example, if cloud.example.net issues access tokens to its clients for later use, and it does so by formatting them as secret-token URIs, tokens that "leak" into places that they don't belong are easier to identify. This could be through a variety of mechanisms; for example, if repo.example.com can be configured to refuse commits containing secret-token URIs, it helps its customers avoid accidental disclosures.</t>
      <t>secret-token URIs are intended to aid in identification of generated secrets like API keys and similar tokens. They are not intended for use in controlled situations where ephemeral tokens are used, such as things like Cross-Site Request Forgery (CSRF) tokens.</t>
      <section anchor="notational-conventions" numbered="true" toc="default">
        <name>Notational Conventions</name>
        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
    NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>

        <t>This document uses ABNF <xref target="RFC5234" format="default"/>. It also uses the pchar rule from <xref target="RFC3986" format="default"/>.</t>
      </section>
    </section>
    <section anchor="the-secret-token-uri-scheme" numbered="true" toc="default">
      <name>The secret-token URI scheme</name>
      <t>The secret-token URI scheme identifies a token that is intended to be a secret.</t>
<sourcecode type=""><![CDATA[
secret-token-URI    = secret-token-scheme ":" token
secret-token-scheme = "secret-token"
token               = 1*pchar
]]></sourcecode>
      <t>See <xref target="RFC3986" sectionFormat="comma" section="3.3"/> for a definition of pchar. Disallowed characters - including non-ASCII characters - <bcp14>MUST</bcp14> be encoded into UTF-8 <xref target="RFC3629" format="default"/> and then percent-encoded (<xref target="RFC3986" sectionFormat="comma" section="2.1"/>).</t>
      <t>When a token is both generated and presented for authentication, the entire URI <bcp14>MUST</bcp14> be used,
without changes.</t>
      <t>For example, given the URI:</t>
<sourcecode type=""><![CDATA[
secret-token:E92FB7EB-D882-47A4-A265-A0B6135DC842%20foo
]]></sourcecode>
      <t>This string (character-for-character, case-sensitive) will both be issued by the token authority, and required for later access. Therefore, if the example above were used as a bearer token in <xref target="RFC6750" format="default"/>, a client might send:</t>
<sourcecode type=""><![CDATA[
GET /authenticated/stuff HTTP/1.1
Host: www.example.com
Authorization: Bearer secret-token:E92FB7EB-D882-47A4-A265-A0B6135DC842%20foo
]]></sourcecode>
    </section>
    <section anchor="iana-considerations" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This document registers the following value in the URI Scheme registry:</t>
      <dl newline="false" spacing="compact">
        <dt>Scheme name:</dt>
	<dd>secret-token</dd>
        <dt>Status:</dt>
	<dd>provisional</dd>
        <dt>Applications / protocols that use this scheme:</dt>
	<dd>none yet</dd>
        <dt>Contact:</dt>
	<dd>iesg@iesg.org</dd>
        <dt>Change Controller:</dt>
	<dd>IESG</dd>
        <dt>References:</dt>
	<dd>(this document)</dd>
      </dl>
    </section>
    <section anchor="security-considerations" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>The token ABNF rule allows tokens as small as one character. This is not recommended practice; applications should evaluate their requirements for entropy and issue tokens correspondingly.
See <xref target="RFC4086" format="default"/> for more information.</t>
      <t>This URI scheme is intended to reduce the incidence of accidental disclosure; it cannot prevent intentional disclosure.</t>
      <t>If it is difficult to correctly handle secret material, or unclear as to what the appropriate handling is, users might choose to obfuscate their secret tokens in order to evade detection (for example, removing the URI scheme for storage). Mitigating this risk is often beyond the reach of
the system using the secret-token URI, but they can caution users against such practices, and
provide tools to help.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>

<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5234.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3629.xml"/>

      </references>
      <references>
        <name>Informative References</name>

<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6750.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4086.xml"/>


      </references>
    </references>
    <section anchor="acknowledgements" numbered="true" toc="default">
      <name>Acknowledgements</name>
      <t>The definition of bearer tokens is from <xref target="RFC6750" format="default"/>.</t>
    </section>
  </back>
</rfc>
