Skip to content

fix(notify): keep untrusted Telegram fields on one line - #896

Open
thecorporatetractor wants to merge 1 commit into
BaaRai:mainfrom
thecorporatetractor:fix/telegram-oneline
Open

thecorporatetractor wants to merge 1 commit into
BaaRai:mainfrom
thecorporatetractor:fix/telegram-oneline

Conversation

@thecorporatetractor

Copy link
Copy Markdown
Contributor

Problem

Telegram notifications write untrusted fields as they are. A newline in a finding title adds a fake entry to a digest: a finding named a\n2. Critical · fake entry shows as two entries. A newline in the vulnerability class or an asset adds a fake line to a single notification.

Slack already flattens these fields with OneLine (notify/slack.go, TestSlackKeepsUntrustedFieldsOnOneLine). The Markdown and Feishu channels flatten them through markdownText, and email is HTML. Telegram was the one channel left.

Behavior change

Telegram flattens the digest line and the Type and Assets fields with OneLine, as Slack does. The single-message title was already flattened by markdownTitle.

Tested

TestTelegramKeepsUntrustedFieldsOnOneLine (in notify/channels_test.go) mirrors the Slack test: newlines in the class, an asset and a digest title no longer create lines. It fails before the change. go test ./notify/, gofmt and vet pass.

Slack flattens titles, types and assets with OneLine so a newline in an
untrusted field cannot forge another line (TestSlackKeepsUntrustedFieldsOnOneLine).
Telegram did not: a finding named "a\n2. Critical · fake entry" added a
forged entry to a digest, and a newline in the vulnerability class or an
asset added a forged line to a single notification. Flatten the digest
line and the Type and Assets fields the same way.
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