@@ -34,6 +34,7 @@ author:
34343535
3636normative :
37+ RFC6265 :
3738
3839informative :
3940 BLOG :
@@ -46,21 +47,161 @@ informative:
4647
4748--- abstract
4849
49- TODO Abstract
50-
50+ Redirecting HTTP requests to HTTPS, a common pattern for human-facing web
51+ resources, can be an anti-pattern for authenticated API traffic. This document
52+ discusses the pitfalls and makes deployment recommendations for authenticated
53+ HTTP APIs. It does not specify a protocol.
5154
5255--- middle
5356
5457# Introduction
5558
56- TODO Introduction
59+ It is a common pattern for HTTP servers to prefer serving resources over HTTPS.
60+ Because HTTPS uses TLS, clients receive authentication of the server and
61+ confidentiality of the resource bodies supplied by the server.
62+
63+ In order to implement this preference, HTTP servers often listen for unencrypted
64+ requests and respond with a 3XX status code directing the client to the
65+ equivalent resource over an encrypted connection. For unauthenticated web
66+ browsing, this is a reasonable user experience bridge. Users often type bare
67+ hostnames (not URIs) into a user agent; if the user agent defaults to an
68+ unencrypted connection, the server can correct this default and require the use
69+ of encryption. This pattern is so well established that many HTTP server and
70+ intermediary implementations have a prominently displayed option to enable it
71+ automatically.
72+
73+ When client authentication is used, more care must be taken. The client's
74+ initial request may include a Bearer token or other credential; once the request
75+ has been sent on the network, any passive attacker who can see the traffic can
76+ acquire this credential and use it.
77+
78+ If the server performs a redirect in this situation, it does not mitigate
79+ exposure of the credential. Further, because the request will ultimately succeed
80+ if the client follows the redirect, an application developer or user who
81+ accidentally configures an unencrypted API endpoint will not necessarily notice
82+ the misconfiguration.
5783
84+ This document describes actions API servers and clients should take in order to
85+ safeguard credentials. These recommendations are not directed at resources where
86+ no authentication is used.
5887
59- # Conventions and Definitions
88+
89+ # # Conventions and Definitions
6090
6191{::boilerplate bcp14-tagged}
6292
6393
94+ # Server Recommendations
95+
96+ # # Pre-Connection Redirects
97+
98+ Various mechanisms exist to inform clients that unencrypted requests to a server
99+ are never appropriate :
100+
101+ - HTTP Strict Transport Security (HSTS) {{!RFC6797}} informs clients who make a
102+ successful connection over HTTPS that secure connections are a requirement in
103+ the future.
104+ - HTTPS DNS records {{!RFC9460}} inform clients at connection time to use only
105+ secure connections to the indicated server.
106+
107+ Neither mechanism is foolproof. An attacker with control of the network or the
108+ DNS server could block resolution of HTTPS records on a client connecting to a
109+ new server, while HSTS requires a successful prior connection to the server and
110+ relies on the client to implement persistent storage of the HSTS directive.
111+
112+ Used together, however, both approaches make clients less likely to send any
113+ requests over an insecure channel. Servers with authenticated endpoints SHOULD
114+ employ both mechanisms.
115+
116+ # # Connection Blocking
117+
118+ If an API request succeeds despite having an unencrypted endpoint configured,
119+ the developer or user is less likely to notice the misconfiguration. Where
120+ possible, it is advantageous for such a misconfiguration to fail immediately so
121+ that the error can be noticed and corrected.
122+
123+ Servers MAY induce such an early failure by not accepting unencrypted
124+ connections, e.g. on port 80. This makes it impossible for a client to send a
125+ credential over an insecure channel to the authentic server, as no such channel
126+ can be opened.
127+
128+ However, this mitigation is limited against active network attackers, who can
129+ impersonate the server and accept the client's insecure connection attempt.
130+
131+ # # Credential Restriction
132+
133+ Whenever possible, credentials should include an indicator to clients that the
134+ credential is restricted to secure contexts. For example, Cookie-based
135+ authentication SHOULD include the Secure attribute described in {{Section
136+ 4.1.2.5 of RFC6265}}. Bearer tokens MAY use the format described in {{?RFC8959}}
137+ to indicate the expected usage to the client.
138+
139+ # # Credential Revocation
140+
141+ Some deployments may not find it feasible to completely block unencrypted
142+ connections, whether because the hostname is shared with unauthenticated
143+ endpoints or for infrastructure reasons. Therefore, servers need a response for
144+ when a valid credential has been received over an insecure channel.
145+
146+ Because a difference in behavior would enable attackers to guess and check
147+ possible credentials, a server MUST NOT return a different client response
148+ between a valid or invalid credential presented over an insecure connection.
149+ Differences in behavior MUST only be visible on subsequent use of the credential
150+ over a secure channel.
151+
152+ When a request is received over an unencrypted channel, the presented credential
153+ is potentially compromised. Servers SHOULD revoke such credentials immediately.
154+ When the credential is next used over a secure channel, a server MAY return an
155+ error that indicates why the credential was revoked.
156+
157+ # Client Recommendations
158+
159+ The following recommendations increase the success rate of the server
160+ recommendations above.
161+
162+ # # Implement Relevant Protocols
163+
164+ Clients SHOULD support and query for HTTPS records {{!RFC9460}} when
165+ establishing a connection and SHOULD respect HSTS headers {{!RFC6797}} received
166+ from a server. This includes implementing persistent storage of HSTS indications
167+ received from the server.
168+
169+ # # Respect Credential Restrictions
170+
171+ Clients MUST NOT send a Cookie with the Secure attribute {{RFC6265}} over an
172+ insecure channel. Clients MUST NOT send an Authorization header containing a
173+ token whose value begins with "secret-token:" over an insecure channel.
174+
175+ # # Disallow Insecure by Default
176+
177+ When authentication is used, clients SHOULD require an explicit indication from
178+ the user or caller that an insecure context is expected. Without such an
179+ indication, attempts to send credentials should fail without producing any
180+ network traffic.
181+
182+ # Security Considerations
183+
184+ This entire document is about security of HTTP API interactions.
185+
186+ The behavior recommended in {{credential-revocation}} creates the potential for
187+ a denial of service attack where an attacker guesses many possible credentials
188+ over an unencrypted connection in hopes of discovering and revoking a valid one.
189+ Servers implementing this mitigation MUST also guard against such attacks, such
190+ as by limiting the number of requests before closing the connection and
191+ rate-limiting the establishment of insecure connections.
192+
193+
194+ # IANA Considerations
195+
196+ This document has no IANA actions.
197+
198+
199+ --- back
200+
201+ # Acknowledgments
202+
203+ We are grateful to Joachim Viide for his {{BLOG}} blog posting that brought up the issue.
204+
64205# Notes
65206
66207I don't disagree with the thrust of the article, but I take a different
@@ -112,18 +253,3 @@ it was not a perfect match. Thats why I ended up emulating Stripe with status
112253code 403, which "indicates that the server understood the request but refuses
113254to fulfill it." A bit more open-ended, but not a perfect match either.
114255
115- # Security Considerations
116-
117- This entire document is about security of HTTP API interactions.
118-
119- # IANA Considerations
120-
121- This document has no IANA actions.
122-
123-
124- --- back
125-
126- # Acknowledgments
127- {:numbered="false"}
128-
129- We are grateful to Joachim Viide for his {{BLOG}} blog posting that brought up the issue.
0 commit comments