Skip to content

runtime: blacklist /dev, /proc and /sys from watch dirs.#3165

Merged
htuch merged 5 commits intoenvoyproxy:masterfrom
htuch:server-fuzz
Apr 24, 2018
Merged

runtime: blacklist /dev, /proc and /sys from watch dirs.#3165
htuch merged 5 commits intoenvoyproxy:masterfrom
htuch:server-fuzz

Conversation

@htuch
Copy link
Copy Markdown
Member

@htuch htuch commented Apr 23, 2018

server_test proto fuzzing resulted in OOM because of /dev traversal. It
seems bad to allow runtime paths to point in these places.

Risk Level: Low
Testing: New unit tests.

Signed-off-by: Harvey Tuch htuch@google.com

server_test proto fuzzing resulted in OOM because of /dev traversal. It
seems bad to allow runtime paths to point in these places.

Risk Level: Low
Testing: New unit tests.

Signed-off-by: Harvey Tuch <htuch@google.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Seems OK though it still feels a bit platform specific to me. I had some comments on some additional follow ups we might want to do.


void DiskLayer::walkDirectory(const std::string& path, const std::string& prefix) {
ENVOY_LOG(debug, "walking directory: {}", path);
// Check if this is an obviously bad path.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Per offline convo, I still think the correct solution here is a max recursion check. Can we TODO that? Additionally, It seems like we should potentially do this check in any place we attempt to load a file (TLS certs, etc.)? Should we issue/TODO that also?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agree. Added TODO for recursion depth and filed #3170.

@mattklein123 mattklein123 self-assigned this Apr 23, 2018
@htuch htuch mentioned this pull request Apr 23, 2018
Signed-off-by: Harvey Tuch <htuch@google.com>
// TODO(htuch): When we are using C++17, switch to std::filesystem::canonical.
char* resolved_path = ::realpath(path.c_str(), nullptr);
if (resolved_path == nullptr) {
throw EnvoyException(fmt::format("Unable to determine canonical path for {}", path));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you cover this case? Perhaps if you just pass realpath() a bogus path? (I'm not sure what the OSX issue was).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is covered in FilesystemImpl.CanonicalPathFail.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah OK sorry.

Signed-off-by: Harvey Tuch <htuch@google.com>
const std::string path_;
Api::OsSysCalls& os_sys_calls_;
// Maximum recursion depth for walkDirectory().
const uint32_t MaxWalkDepth = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would go higher here. This might even be about where we are with our normal topology. Maybe 20?

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch merged commit 0796c0f into envoyproxy:master Apr 24, 2018
@htuch htuch deleted the server-fuzz branch April 24, 2018 13:47
ramaraochavali pushed a commit to ramaraochavali/envoy that referenced this pull request May 3, 2018
…3165)

server_test proto fuzzing resulted in OOM because of /dev traversal. It
seems bad to allow runtime paths to point in these places.

Risk Level: Low
Testing: New unit tests.

Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Rama <rama.rao@salesforce.com>
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