Skip to content

Commit a1a6e8f

Browse files
keeferrourkesvc-squareup-copybara
authored andcommitted
If a slack signing secret is not exactly the expected 32 bytes
of hex, then okio will throw an error and log the secret. Stop doing that. GitOrigin-RevId: bdd47345c2bb6f5723b188e8fb16c5287ea3e5d7
1 parent dc4d91a commit a1a6e8f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

misk-slack/src/main/kotlin/misk/slack/webapi/interceptors/SlackSignedRequestsInterceptor.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ class SlackSignedRequestsInterceptor @Inject constructor(
2121
private val clock: Clock,
2222
slackConfig: SlackConfig,
2323
) : NetworkInterceptor {
24-
private val signingSecret = slackConfig.signing_secret.value.decodeHex()
24+
// Trim to remove errant newlines or whitespace that could be in the secret text.
25+
private val signingSecret = try {
26+
slackConfig.signing_secret.value.trim().decodeHex()
27+
} catch (e: IllegalArgumentException) {
28+
// Okio will throw an exception containing the secret if it cannot decode it.
29+
// Suppress that to avoid leaking the secret in logs.
30+
throw IllegalArgumentException("Could not parse the slackConfig.signing_secret.value")
31+
}
2532

2633
/**
2734
* The SlackSignedRequestsInterceptor verifies that the incoming request is

0 commit comments

Comments
 (0)