Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate interface name passed in ECS_OFFHOST_INTROSPECTION_INTERFACE_NAME #4275

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented Aug 8, 2024

Summary

ECS_OFFHOST_INTROSPECTION_INTERFACE_NAME allows system administrators to input an interface name in the ecs.config file. This user input is then passed into an exec iptables command here:

func getBlockIntrospectionOffhostAccessInputChainArgs() []string {
return []string{
"INPUT",
"-p", "tcp",
"-i", defaultOffhostIntrospectionInterface,
"--dport", agentIntrospectionServerPort,
"-j", "DROP",
}
}
func getOffhostIntrospectionInterface() (string, error) {
s := os.Getenv(offhostIntrospectonAccessInterfaceEnv)
if s != "" {
return s, nil
}
return getDefaultNetworkInterfaceIPv4()
}

ecs.config is a protected file that only the root user has write access to, so the threat is limited. But we should still validate that this is a valid linux interface name anyways, so that this env var cannot be used to inject an unexpected command into the middle of this iptables command.

Testing

New tests cover the changes: yes

Description for the changelog

Enhancement: Validate ECS_OFFHOST_INTROSPECTION_INTERFACE_NAME is a valid interface name.

Licensing

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

@sparrc sparrc requested a review from a team as a code owner August 8, 2024 18:02
ecs-init/exec/iptables/iptables.go Outdated Show resolved Hide resolved
ecs-init/exec/iptables/iptables.go Outdated Show resolved Hide resolved
@sparrc sparrc force-pushed the ifname branch 3 times, most recently from 721a74a to eeb3928 Compare August 8, 2024 19:29
@sparrc sparrc added the bot/test label Aug 8, 2024
@sparrc sparrc merged commit b02155d into aws:dev Sep 14, 2024
40 checks passed
@Yiyuanzzz Yiyuanzzz mentioned this pull request Sep 20, 2024
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.

4 participants