<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN" "http://xml.resource.org/authoring/rfc2629.dtd" [
  <!ENTITY rfc2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
  <!ENTITY rfc2617 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2617.xml">
  <!ENTITY rfc3230 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3230.xml">
  <!ENTITY rfc3447 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3447.xml">
  <!ENTITY rfc4648 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4648.xml">
  <!ENTITY rfc5246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
  <!ENTITY rfc6376 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6376.xml">
  <!ENTITY rfc6749 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6749.xml">
  <!ENTITY rfc7230 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7230.xml">
  <!ENTITY rfc7235 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7235.xml">
  <!ENTITY jwa SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-jose-json-web-algorithms-20.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xsl" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc toc="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc symrefs="yes" ?>
<rfc category="std" ipr="trust200902" submissionType="independent"
     docName="draft-sporny-http-proofs-01">
<front>
 <title>Proof-based Authentication for HTTP Messages</title>

 <author initials="M.S." surname="Sporny" fullname="Manu Sporny">
  <organization>Digital Bazaar</organization>
  <address>
   <postal>
    <street>1700 Kraft Drive</street>
    <street>Suite 2408</street>
    <city>Blacksburg</city> <region>VA</region>
    <code>24060</code>
    <country>US</country>
   </postal>
   <phone>+1 540 961 4469</phone>
   <email>msporny@digitalbazaar.com</email>
   <uri>http://manu.sporny.org/</uri>
  </address>
 </author>

 <author initials="D.L." surname="Longley" fullname="Dave">
  <organization>Digital Bazaar</organization>
  <address>
   <postal>
    <street>1700 Kraft Drive</street>
    <street>Suite 2408</street>
    <city>Blacksburg</city> <region>VA</region>
    <code>24060</code>
    <country>US</country>
   </postal>
   <phone>+1 540 961 4469</phone>
   <email>dlongley@digitalbazaar.com</email>
   <uri>https://github.com/dlongley</uri>
  </address>
 </author>

 <date month="June" year="2015" />
 <area>Security</area>
 <workgroup></workgroup>
 <keyword>HTTP</keyword>
 <keyword>authentication</keyword>
 <keyword>mathematical proof</keyword>
 <keyword>proof of work</keyword>
 <keyword>proof of patience</keyword>
 <keyword>proof of navigation</keyword>
 <abstract>
  <t>
For a client to access a particular resource on the Web, a server must
expend a certain amount of computational effort to respond to the request. In
some cases this computational effort is sizeable and the server may want to
only respond to certain clients. For example, in a distributed
denial-of-service attack, a server may require all clients to expend a
certain amount of resources via a client-run proof-of-work algorithm to
throttle the number of incoming requests to a more manageable number. This
document details a new authentication scheme for HTTP that may be used to
request and transmit proofs in HTTP headers.
  </t>
 </abstract>
 <note title="Feedback">
  <t>
This specification is a thought exercise that may be submitted on a
standardization track in the future. Feedback related to this specification
should be sent to
<eref target="mailto:msporny@digitalbazaar.com">msporny@digitalbazaar.com</eref>.
  </t>
 </note>
</front>

<middle>

 <section anchor="intro" title="Introduction">
  <t>
This protocol extension is intended to provide a simple and standard way for
clients and servers to request and transmit proofs to one another.
  </t>

  <t>
For a client to access a particular resource on the Web, a server must
expend a certain amount of computational effort to respond to the request. In
some cases this computational effort is sizeable and the server may want to
only respond to certain clients. For example, in a distributed
denial-of-service attack, a server may require all clients to expend a
certain amount of resources via a client-run proof-of-work algorithm to
throttle the number of incoming requests to a more manageable number.
  </t>

  <t>
Fundamentally, proofs need to separate clients that are using the system in
good faith versus clients that are attempting to attack the system. In order
to do this, a proof must be selected that creates a net economic loss to
an attacker of the system while also not making legitimate uses of the system
too costly. Proofs must be tuned to the type of protection the server would
like to apply to a target resource.
  </t>

  <t>
There are many classes of proofs that can be used by a server to identify
legitimate clients. Some of these include proof of work, proof of navigation,
proof of humanity, and proof of patience. A proof of work typically
requires a time consuming mathematical puzzle to be solved, such as
prime factorization. A proof of navigation requires tokens to be fetched from
a list of servers on a network in a particular order. A proof of humanity
requires a problem to be solved, like identifying an emotion in an image,
that cannot easily be determined by a computer. A proof of patience requires
a client to prove that it has waited for a certain period of time before being
allowed to have access to a particular resource on a server.
  </t>
 </section>

 <section anchor="components" title="The Components of a Proof">
  <t>
There are a number of components in a proof that are common between the
'Proof' HTTP Authentication Scheme. This section details the components of a
HTTP Proof.
  </t>

   <section anchor="params" title="Proof Parameters">

    <t>
The following section details the proof parameters.
    </t>

    <section anchor="type" title="type">
     <t>
REQUIRED.  The `type` field specifies the specific proof algorithm that is
employed by the rest of the parameters. The value of this
field SHOULD be a registered algorithm as defined in the Proof Algorithm
Registry.
     </t>
    </section>

   </section>

   <section anchor="ambiguity" title="Ambiguous Parameters">
    <t>
If any of the parameters listed above are erroneously duplicated in the
associated header field, then the last parameter defined MUST be used. Any
parameter that is not recognized as a parameter, or is not well-formed,
MUST be ignored.
    </t>
   </section>

 </section>

 <section anchor="auth-scheme" title="The 'Proof' HTTP Authentication Scheme">

  <t>
The "Proof" authentication scheme is based on the model that the client must
establish a solution (aka proof) to a challenge posed by the server. The
scheme is parameterized enough such that it is not bound to any particular
proofing algorithm.
  </t>

  <section anchor="auth-header" title="The Authorization Header">

   <t>
The client is expected to send an Authorization header
(as defined in
<xref target="RFC7235">RFC 7235</xref>, <eref
target="http://tools.ietf.org/html/draft-ietf-rfc7235-auth-25#section-4.1">
Section 4.1</eref>) where the "auth-scheme" is "Proof" and the
"auth-param" parameters meet the requirements listed in
Section 2: The Components of a Proof and the specific parameters for the
proof algorithm being used.
   </t>

   <t>

    <figure>
     <artwork>
Authorization: Proof type=example, foo=bar
     </artwork>
    </figure>
   </t>

   <t>
Note: The example above uses 'example', 'foo', and 'bar' for purely
illustrative purposes. A real example is provided in the section below titled
`Proof of Patience`.
   </t>

   <section anchor="auth-ipa" title="Initiating Proof Authorization">

    <t>
A server may notify a client when a protected resource could be accessed by
authenticating itself to the server via a proof. To initiate this process, the
server will request that the client authenticate itself via a 401 response code.
The server should specify which type of proof it would like to have established
in the WWW-Authenticate header.
    </t>

    <t>
The example below is provided to illustrate a generic proof flow, but the
proof parameters are only for illustrative purposes. A more specific example
is included in the section titled "Proof of Patience". Given the
following request:
    </t>

    <figure>
     <artwork>
GET /examples/protected HTTP/1.1
Host: example.com
     </artwork>
    </figure>

    <t>
The following request for a proof is supplied by the server via
the WWW-Authenticate header:
    </t>

    <figure>
     <artwork>
HTTP/1.1 401 Unauthorized
Date: Thu, 05 Jul 2015 21:31:41 GMT
Content-Length: 1234
Content-Type: text/html
WWW-Authenticate: Proof type=example, foo=bar

...
     </artwork>
    </figure>

    <t>
The client performs what is necessary given the proof and then transmits the
established proof back to the server via the `Authorization` header.
    </t>

    <figure>
     <artwork>
GET /examples/protected HTTP/1.1
Host: example.com
Date: Thu, 05 Jul 2015 21:46:52 GMT
Authorization: Proof type=example, foo=bar
     </artwork>
    </figure>

    <t>
The server would then verify the proof and fulfill the request if the proof
is valid.
    </t>

  </section>
 </section>
 </section>

 <section anchor="proof-of-patience" title="Proof of Patience">
  <t>
The Proof of Patience algorithm is a type of proof that demonstrates that a
client waited for a certain period of time before attempting a request.
  </t>
   <section anchor="pop-params" title="Proof of Patience Parameters">
    <section anchor="pop-type" title="type">
     <t>
REQUIRED.  The `type` field must be set to `patience`.
     </t>
    </section>
    <section anchor="pop-token" title="token">
     <t>
REQUIRED.  The `token` field is typically a server-encrypted secret that,
when retransmitted to the server after a defined wait period, proves that the
client has waited a certain amount of time that was requested by the server.
It is important that the server specify the amount of time to wait via
the `Retry-After` HTTP Header. The client should wait until the number of
seconds specified in `Retry-After` has elapsed. The client should then attempt
the initial request again with the contents supplied in the `WWW-Authenticate`
copied into a new `Authorization` header.
     </t>
     <t>
The contents of the token is specific to the server. For example, the token
could contain the requesting IP of the client, the specific HTTP resource the
token is tied to, and the time period when the token is valid. The server
could then encrypt the data, base64 encode it, and set `token` to the
encrypted, base64-encoded value. This ensures that the client cannot tamper
with the data and can simply re-transmit the token back to the server after
a certain period of time has elapsed to establish the proof of patience.
     </t>
    </section>
   </section>

   <section anchor="pop-example" title="Proof of Patience Example">

    <t>
For example, given the following HTTP request:
    </t>

    <figure>
     <artwork>
POST /examples HTTP/1.1
Host: example.com
Date: Thu, 05 Jul 2015 21:31:40 GMT
Content-Type: application/json
Content-Length: 3

{}
     </artwork>
    </figure>

    <t>
The following request for a proof of patience is supplied by the server via
the WWW-Authenticate header:
    </t>

    <figure>
     <artwork>
HTTP/1.1 401 Unauthorized
Date: Thu, 05 Jul 2015 21:31:41 GMT
Content-Length: 1234
Content-Type: text/html
WWW-Authenticate: Proof type=patience, token="jA0EAwMpYIIz/X7aE+u3ADHjb4="
Retry-After: 30

...
     </artwork>
    </figure>

    <t>
The client then waits for 30 seconds, as specified in the `Retry-After` header,
and then transmits the proof of patience back to the server via the
`Authorization` header.
    </t>

    <figure>
     <artwork>
POST /examples HTTP/1.1
Host: example.com
Date: Thu, 05 Jul 2015 21:32:11 GMT
Content-Type: application/json
Content-Length: 3
Authorization: Proof type=patience, token="jA0EAwMpYIIz/X7aE+u3ADHjb4="

{}
     </artwork>
    </figure>

    <t>
The server would then decrypt the token and verify that the contents of the
token meet the proof of patience requirement. If the verification is successful,
the server would fulfill the request.
    </t>

  </section>
 </section>

</middle>
<back>
 <references title="Normative References">
  &rfc2119;
  &rfc4648;
  &rfc6376;
  &rfc7230;
  &rfc7235;
  &jwa;
 </references>
 <references title="Informative References">
  &rfc2617;
  &rfc3230;
  &rfc3447;
  &rfc5246;
  &rfc6749;
 </references>

 <section anchor="appendix-a" title="Security Considerations">
  <t>
Editor's note: Clearly there are a number of concerning reverse denial
of service attacks that could be executed over non-HTTPS connections. A
simple header injection could keep a client spinning for a very long time in
the event of a proof of work (e.g. by corrupting the number of iterations to
perform). More thinking needs to be put into this section.
  </t>
 </section>

 <section anchor="appendix-b" title="Extensions">
  <t>
This specification was designed to be simple, modular, and extensible.
Developers that desire more functionality than this specification provides
are urged to ensure that an extension specification doesn't already exist
before implementing a proprietary extension.
  </t>

  <t>
If extensions to this specification are made by adding new Proof
Parameters, those extension parameters MUST be registered in the
Proof Parameter Registry. The registry will be created and
maintained at (the suggested URI)
<eref target="http://www.iana.org/assignments/http-proof-parameters">
http://www.iana.org/assignments/http-proof-parameters</eref>. An
example entry in this registry is included below:

   <figure>
    <artwork>
Proof Parameter: iterations
Reference to specification: [SOME_ALGORITHM], Section XYZ.
Notes (optional): The `iterations` parameter is used to specify the number
of iterations to run on the mathematical proof algorithm.
    </artwork>
   </figure>
  </t>
 </section>

 <section anchor="appendix-c" title="Test Values">
  <t>
   Provide a simple test of a Proof of Patience.
   <figure>
    <artwork>

    </artwork>
   </figure>

  </t>

  <section anchor="default-test" title="Default Test">
   <t>
    <figure>
     <artwork></artwork>
   </figure>
   </t>

 </section>
 </section>
 <section anchor="acknowledgements" title="Acknowledgements">
  <t>
The editor would like to thank the following individuals for feedback on and
implementations of the specification (in alphabetical order): None yet.
  </t>
 </section>
 <section anchor="appendix-d" title="IANA Considerations">
  <section anchor="iana-scheme" title="Signature Authentication Scheme">
   <t>
The following entry should be added to the Authentication Scheme Registry
located at <eref target="http://www.iana.org/assignments/http-authschemes">
http://www.iana.org/assignments/http-authschemes</eref>
   </t>
   <t>
Authentication Scheme Name: Proof<vspace/>
Reference: [RFC_THIS_DOCUMENT], Section 2.<vspace/>
Notes (optional): The Proof scheme is designed for clients to
authenticate themselves with a server by performing a mathematical proof.
   </t>
  </section>
  <section anchor="sa-registry" title="Proof Algorithm Registry">
   <t>
The following initial entries should be added to the Proof Algorithm
Registry to be created and maintained at (the suggested URI)
<eref target="http://www.iana.org/assignments/proof-algorithms">
http://www.iana.org/assignments/proof-algorithms</eref>:
   </t>
   <t>
Algorithm Name: patience<vspace/>
Reference: [SCRYPT_RFC_WHEN_IT_EXISTS]
Status: active
   </t>
  </section>

 </section>
</back>
</rfc>
