Skip to content

Conversation

banks
Copy link
Contributor

@banks banks commented Jun 14, 2019

Signed-off-by: Paul Banks banks@banksco.de

Description:

As noted in #7528 the newly added sanity checking of possibly sensitive file paths prevents legitimate usage of passing bootstrap via a non-CLOEXEC file descriptor from a generator helper that execs Envoy.

This PR relaxes the validation such that any path resolving to a canonical path with the prefix /dev/fd/ is considered valid.

Risk Level: Low
Testing: Unit test case is added that was failing before the change and passes afterwards. In addition I've manually verified that the old behaviour of allowing /dev/fd/ paths works with my dev binary.
Docs Changes: None, I didn't find this limitation documented currently.
Release Notes: N/A (I didn't see the original change to make /dev invalid in 1.10 notes so I assume this doesn't warrant going in either.)

Fixes #7258

@banks
Copy link
Contributor Author

banks commented Jun 14, 2019

Hmm the test failure seems legit - at least filesystem_impl_test is failing in CI. Passed on my machine. I'll take a look.

@lizan
Copy link
Member

lizan commented Jun 14, 2019

@banks I guess it is due to on some system {/dev/fd,/0} is a symlink, so the canonical path is outside of it. on my Linux /dev/fd/0 points to /dev/pts/4 (where it links to depends on the process I think.

@banks
Copy link
Contributor Author

banks commented Jun 15, 2019 via email

// /dev/fd/* _before_ resolving the canonical path.
if (absl::StartsWith(path, "/dev/fd/")) {
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be the simplest approach here rather than trying to research all the different OS implementations of this path and white list every possible ending point.

I'm not sure if there are any specific downsides of bypassing realpath here?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delay, been catching up on backlog after OOO. I think this is fine for now, but can you leave a TODO to switch to https://en.cppreference.com/w/cpp/filesystem/absolute when we have C++17? The main downside of what you have is that there is no relative path normalization, which we want independent of symlink following.
/wait

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the TODO. I hope this is appropriate - I added it under your username as it seems to be more likely you will have context for this later than I will!

@banks
Copy link
Contributor Author

banks commented Jun 17, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #7279 (comment) was created by @banks.

see: more, trace.

@banks
Copy link
Contributor Author

banks commented Jun 17, 2019

Coverage test fail downloading some dependency...

@stale
Copy link

stale bot commented Jun 24, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 24, 2019
@banks
Copy link
Contributor Author

banks commented Jun 24, 2019

@htuch since you were assigned on the issue, would this be of interest to merge? Thanks!

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jun 24, 2019
@stale
Copy link

stale bot commented Jul 6, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 6, 2019
@banks
Copy link
Contributor Author

banks commented Jul 7, 2019 via email

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jul 7, 2019
htuch
htuch previously approved these changes Jul 9, 2019
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch
Copy link
Member

htuch commented Jul 9, 2019

@banks yep. Can you squash, fix DCO and force push? I can merge when CI DCO check passes.

@htuch htuch added the waiting label Jul 9, 2019
Signed-off-by: Paul Banks <banks@banksco.de>
@banks
Copy link
Contributor Author

banks commented Jul 11, 2019

@htuch sorry, been travelling this week I think this should all be good to go now once CI completes.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch htuch merged commit fcec70f into envoyproxy:master Jul 12, 2019
@banks banks deleted the allow-dev-fd-config branch July 12, 2019 13:26
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.

Consider relaxing /dev config file restrictions for /dev/fd/*
3 participants