Skip to content

Safe logging of attributes through limiting their length #3301

Open

Description

@pbleser-oc

Is your feature request related to a problem? Please describe.

A lot of the values of the log attributes are coming from inbound requests (e.g. trace-id, username, ...), and there is some risk of log pollution "attacks" by hammering in requests with very long values for those.

They typically end up clogging up disk space, but also log collectors/aggregators and search engines such as Graylog.

Thus, for values that come from requests instead of constants or configuration settings, it might be advisable to limit their length.

Describe the solution you'd like

Use wrappers for string values and string array values in logging calls to limit their maximum lengths, to avoid log pollution.

Additional context

Already implemented in the groupware branch:

logger.Error().Err(err).Str("trace-id", log.SafeString(traceIdHeaderValue)).Msg(...)

as well as for arrays of strings that ought to have a maximum amount of items:

logger.Info().Array("addressbookIds", log.SafeStringArray(addressbookIds)).Msg(...)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions