Skip to content

HTTP logs: Redact OAuth tokens and client secrets in bodies - #282

Open
paolostivanin wants to merge 1 commit into
opencloud-eu:mainfrom
paolostivanin:redact-secrets-http-logs
Open

paolostivanin wants to merge 1 commit into
opencloud-eu:mainfrom
paolostivanin:redact-secrets-http-logs

Conversation

@paolostivanin

Copy link
Copy Markdown
Contributor

Problem

With "HTTP logs" enabled, LogInterceptor only redacted the Authorization header. Request and response bodies were logged as they are, so the logs contained:

  • token requests: refresh token, authorization code, PKCE verifier, client secret
  • token responses: access, refresh and id token
  • the client registration response: client_secret

These logs are meant to be shared for support. A 30-day refresh token in them gives access to the account.

Changes

  • The existing redaction setting (redact_auth_header_logs, true by default, configurable via MDM and branding) now also masks these fields in form and JSON bodies. With the setting off, the logs stay complete for debugging.
  • code is only masked in form bodies (token requests), since Graph API errors carry a code field too.
  • LogInterceptor.redactAuthHeader is renamed to redactSecrets, and the MDM strings describe what it covers now. The MDM key does not change.

Follow-up of #237, which stops the app's own log statements from writing tokens.

Testing

  • New tests in LogInterceptorTest: a refresh token request through the interceptor against MockWebServer, checking the captured logs with redaction on and off, plus the authorization code grant, the client registration response, and a Graph-style code field that is kept.
  • kotlin-reflect is added to the library unit test classpath: the interceptor serializes its logs with KotlinJsonAdapterFactory, and the library excludes it (the app gets it from opencloudData).
  • Library unit tests, app compile and detekt pass.

With HTTP logs enabled, only the Authorization header was redacted. The
bodies were logged as they are, so the logs contained the token
requests (refresh token, authorization code, PKCE verifier, client
secret) and the token responses (access, refresh and id token), as well
as the client_secret of the client registration response.

The existing redaction setting (redact_auth_header_logs, true by
default) now also masks these fields in form and JSON bodies. With the
setting off, the logs stay complete for debugging. "code" is only
masked in form bodies, since Graph API errors carry a "code" field too.

The flag is renamed redactSecrets and the MDM strings describe what it
covers now. The MDM key does not change.

kotlin-reflect is added to the library unit tests, the interceptor
needs it to serialize its logs (the app gets it from opencloudData).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant