route.secret_outside_body
A route reads a secret value from a URL or a header.
Area 7, HTTP; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
A URL is written to access logs and proxies' logs, kept in a browser's
history and passed on in a Referer header. A Password in a path or a
query string is read by people it was never meant for, whatever the app
does next, so a secret arrives in a request's JSON body.
A header is for credentials sent on every request. A BearerToken, a
Jwt and an ApiKey may be read from one; a Password, a TotpSecret, a
SecretText and a OneTimeCode are typed once into a form, so they are
not. Authorization and cookies are read by sign-in whatever the type
(route.header_credential).
What it looks like
main.jadpo:
type Handle = Text { max_length: 40}type LoginAccepted = Bool {}type SignInForm = Input { handle: Handle account_password: Password}type SignInAnswer = Output { accepted: LoginAccepted}action sign_in(login_attempt: SignInForm) -> SignInAnswer { return SignInAnswer { accepted: LoginAccepted(login_attempt.account_password == "correct horse battery staple") }}policy { actions: { sign_in: [Access.public] }}routes Logins { prefix: /logins GET / { authentication: RouteAuthentication.none input: SignInForm output: SignInAnswer run: sign_in(input) }}
error SignInForm.account_password reads a Password from the query string
--> main.jadpo:33:16
|33 | input: SignInForm | ^^^^^^^^^^ a secret, in the query string
- reason
- A URL is written to access logs and proxies' logs, kept in a browser's history and passed on in a
Refererheader, so aPasswordin one is read by people it was never meant for. - next
- Take
SignInForm.account_passwordin the JSON body of aPOST,PUTorPATCH, in the route'sinput:(agent) - rule
- route.
secret_ outside_ body - help
- https://jadpo.
dev/docs/errors/route. secret_ outside_ body
(agent) at the end of the next: line means your coding agent can make
the fix itself.
A placeholder is refused the same way:
type ResetPassword = Password {}type ResetAnswer = Output { accepted: Bool}action reset(given: ResetPassword) -> ResetAnswer { return ResetAnswer { accepted: given == "correct horse battery staple" }}policy { actions: { reset: [Access.public] }}routes Resets { prefix: /resets POST /{given: ResetPassword} { authentication: RouteAuthentication.none output: ResetAnswer run: reset(given) }}
error given reads a Password from a URL
--> main.jadpo:22:19
|22 | POST /{given: ResetPassword} { | ^^^^^^^^^^^^^ a secret, in a URL
- reason
- A URL is written to access logs and proxies' logs, kept in a browser's history and passed on in a
Refererheader, so aPasswordin one is read by people it was never meant for. - next
- Take
givenin the JSON body of aPOST,PUTorPATCH, in the route'sinput:(agent) - rule
- route.
secret_ outside_ body - help
- https://jadpo.
dev/docs/errors/route. secret_ outside_ body
How to fix it
Decide how the secret should arrive.
If the secret is typed once into a form, read it from the body of a
POST, PUT or PATCH:
POST / { authentication: RouteAuthentication.none input: SignInForm output: SignInAnswer run: sign_in(input) }
A client now posts the password in the request's JSON, so it stays out of the URL.
If it is a key or a token sent on every request, type it ApiKey,
BearerToken or Jwt and say header::
partner_key: ApiKey { header: "X-Partner-Key" }
The key comes in the header, and the check passes for a key or a token.
Related
Markdown for agents: /docs/errors/route.secret_outside_body.md.Built from Jadpo's main branch at commit 9080dc3.