Skip to main content
ClickHouse hides credentials that appear in queries, table and dictionary definitions, settings and URLs. A hidden value is replaced with [HIDDEN].

What is masked

  • The userinfo of a URL (RFC 3986, section 3.2.1): https://user:password@host/ is shown as https://[HIDDEN]@host/. The whole userinfo is hidden, because a user name alone can be a token.
  • The parameters of presigned or signed URLs: AWS S3 (SigV2 and SigV4, such as X-Amz-Signature, X-Amz-Credential, X-Amz-Security-Token, AWSAccessKeyId, Signature), Google Cloud Storage (X-Goog-*, GoogleAccessId) and Azure SAS (sig).
  • URL query parameters with a common credential name: a name that contains secret, password, passwd, token, credential, signature or key, or is exactly sig, in any case and percent-decoded. For example access_token, api_key and client_secret.
  • The secret fields of known connection strings: Azure (AccountKey, SharedAccessSignature), MongoDB, and the ODBC connection_string.
  • The arguments, settings and dictionary source fields that a function, table function, table engine, database engine or dictionary source declares as secret, such as the access keys of s3, the password of mysql or the password of a dictionary source. A secret argument is masked when it is passed directly as a literal.

Where it applies

The same masking applies wherever a credential could be shown:
  • SHOW CREATE and the create_table_query and engine_full columns of system.tables.
  • The query text in system.query_log, system.processes and the server log. A URL inside a string literal is masked too.
  • Error messages: the message returned to the client, system.query_log.exception, system.errors, system.error_log, the last_exception column of system.dictionaries and the exceptions in system.kafka_consumers.
  • Log messages: the server log, the logs sent to the client and system.text_log, including its value1 to value10 columns.
  • The output of EXPLAIN, unless the user can see secrets (see below), and the texts of system.query_log.query_plan.
  • Other system tables that show a URL, such as system.schema_inference_cache.
In error and log messages, the URL and connection string rules above apply to every URL and connection string in the text, wherever the message comes from. A value that a query hides in its text, such as the key of encrypt or a declared secret argument, is also hidden in the error and log messages of that query, if it is 8 bytes or longer. A user with the displaySecretsInShowAndSelect privilege can see the values in SHOW CREATE and SELECT from system tables when both display_secrets_in_show_and_select and format_display_secrets_in_show_and_select are enabled.

What is not masked

Masking recognizes credentials by where they are, not by what they look like. A credential placed anywhere else is shown as is:
  • A query parameter whose name is not in the list above, for example https://example.com/data.csv?Pr1vate=xxx.
  • A credential in the path of a URL, for example https://example.com/xxx/data.csv.
  • A misspelled or unknown argument name of a table function or engine.
  • A URL that is not valid under RFC 3986.
  • A query that does not parse. Its text is masked only by the URL and connection string rules and by query_masking_rules.
  • A value of a query that an error message or system.query_log.query_plan shows transformed, for example encoded, truncated, split or extracted by a function such as extractURLParameter.
  • A secret argument written as an expression instead of a literal, for example CAST('...' AS Tuple(UInt64, UInt64)) or a value from WITH. The query text hides the expression, but an error or log message may show a value from inside it.
  • A credential written to avoid masking, for example a URL with escaped characters such as 'https:\x2f\x2fuser:password@host/', or a URL assembled with concat. Masking prevents accidental exposure. It does not stop a user who deliberately writes a credential in a form that masking does not recognize.

How to pass credentials

Pass credentials where ClickHouse expects them:
  • The dedicated arguments of a table function or engine, such as the access key arguments of s3.
  • HTTP headers with the headers argument of url and the headers of an HTTP dictionary source, for a service that accepts its token in a header.
  • Named collections, which keep credentials out of queries entirely.

Custom masking rules

To hide other patterns, such as personal data in query texts and log messages, configure query_masking_rules in the server configuration.