Skip to content

Trim whitespace from ENI DNS fields sent by ACS - #5112

Open
arnarpall wants to merge 1 commit into
aws:devfrom
arnarpall:fix/trim-domain-name-servers
Open

Trim whitespace from ENI DNS fields sent by ACS#5112
arnarpall wants to merge 1 commit into
aws:devfrom
arnarpall:fix/trim-domain-name-servers

Conversation

@arnarpall

Copy link
Copy Markdown

Summary

An ENI's DomainNameServers and DomainName values originate from the VPC DHCP option set, which stores each value exactly as it was typed and performs no validation of its own. An option set configured as

    domain-name-servers  10.0.0.2, 10.0.0.3

yields a second value with a leading space. That value was copied verbatim into NetworkInterface and surfaced by the task metadata endpoint, where " 10.0.0.3" is not a valid IP address. A consumer that parses the response strictly fails the whole document rather than the single field, losing unrelated metadata such as the task ARN, cluster and family. Retries do not help because the payload never changes.

Trim surrounding whitespace off each value in InterfaceFromACS, and in the V2N tunnel and VETH pair constructors, which read the same fields from the same payload.

Implementation details

Testing

unit tests implemented an exectuted

New tests cover the changes:

Description for the changelog

  • Bugfix - Trim surrounding whitespace for DomainNameServers and DomainName from VPC DHCP option set

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

An ENI's DomainNameServers and DomainName values originate from the VPC DHCP
option set, which stores each value exactly as it was typed and performs no
validation of its own. An option set configured as

    domain-name-servers  10.0.0.2, 10.0.0.3

yields a second value with a leading space. That value was copied verbatim into
NetworkInterface and surfaced by the task metadata endpoint, where " 10.0.0.3"
is not a valid IP address. A consumer that parses the response strictly fails
the whole document rather than the single field, losing unrelated metadata such
as the task ARN, cluster and family. Retries do not help because the payload
never changes.

Trim surrounding whitespace off each value in InterfaceFromACS, and in the V2N
tunnel and VETH pair constructors, which read the same fields from the same
payload.
@mye956

mye956 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@arnarpall thanks so much for creating this PR. Could you please also run make gomod and then commit the vendor packages within /agent?

// as it was typed and performs no validation of its own. An option set configured as
// "domain-name-servers 10.0.0.2, 10.0.0.3" therefore yields a second value with a leading space,
// which is not a valid IP address by the time it reaches the task metadata response.
func trimSpaceAll(values []*string) []string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the ENIFromACS function (ref) where we could add the same trimming. Although, it doesn't seem like it's used in our codebase anywhere currently. Will leave this up to you if you're up for the task!

@arnarpall arnarpall Sep 2, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I actually did notice this one, and that it was not used anywhere so I decided against adding to it

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.

2 participants