Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/0b4c83e2-93d6-47f1-bcf3-83233e4438b2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "0b4c83e2-93d6-47f1-bcf3-83233e4438b2",
"type": "bugfix",
"description": "Reject carriage return and line feed characters in ECS container authorization tokens",
"module": "aws-config"
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class EcsCredentialsProvider(
?: AwsSdkSetting.AwsContainerAuthorizationToken.resolve(platformProvider)
?: return null

if (token.contains("\r\n")) {
if (token.contains('\r') || token.contains('\n')) {
throw CredentialsProviderException("Token contains illegal line break sequence.")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class EcsCredentialsProviderTest {

@Test
fun testAuthTokenIllegal() = runTest {
val token = "auth\r\ntoken"
listOf("auth\rtoken", "auth\ntoken", "auth\r\ntoken").forEach { token ->
val engine = TestConnection()

val testPlatform = TestPlatformProvider.of(
Expand All @@ -400,12 +400,13 @@ class EcsCredentialsProviderTest {
assertFailsWith<CredentialsProviderException> {
provider.resolve()
}.message.shouldContain("Token contains illegal line break sequence.")
}
}

@Test
fun testAuthTokenFileIllegal() = runTest {
listOf("auth\rtoken", "auth\ntoken", "auth\r\ntoken").forEach { token ->
val tokenFile = "/path/to/token"
val token = "auth\r\ntoken"
val engine = TestConnection()

val testPlatform = TestPlatformProvider.of(
Expand All @@ -422,6 +423,7 @@ class EcsCredentialsProviderTest {
assertFailsWith<CredentialsProviderException> {
provider.resolve()
}.message.shouldContain("Token contains illegal line break sequence.")
}
}

@Test
Expand Down
Loading