X Tutup
The Wayback Machine - https://web.archive.org/web/20230131200320/https://github.com/nodejs/node/pull/46150
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

test: include strace openat test #46150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RafaelGSS
Copy link
Member

Signed-off-by: RafaelGSS rafael.nunu@hotmail.com

Opening it for early feedback. We need to find a way to do it cross-platform, either with other files (openat-linux-syscall, openat-osx-syscall, openat-windows-syscall) or with some magic cross-platform tool.

The idea is to address nodejs/security-wg#827. The CVE-2022-32222 is an example of the purpose of this test.

cc: @nodejs/security-wg @mhdawson

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jan 9, 2023
test/parallel/test-strace-openat-openssl.js Outdated Show resolved Hide resolved

const file = line.match(/"(.*?)"/)[1];
// skip .so reading attempt
if (file.match(/.+\.so(\.?)/) !== null) {
Copy link
Member

Choose a reason for hiding this comment

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

It might actually not be that bad to assert these as well – if we added a new .so dependency on Linux, we might want to know about that?

Copy link
Member Author

Choose a reason for hiding this comment

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

In my case, it's reading the .so from shared locations, for instance: "/home/rafaelgss/.gvm/pkgsets/go1.15/global/overlay/lib/libpthread.so.0". How would we handle it?

Copy link
Member

Choose a reason for hiding this comment

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

You could assert just the filename, ignoring the rest of the path, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. That CVE mentioned in the PR description is really about it. Reading a file/library from an unexpected path.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, please don’t consider this a blocking comment. This would test something different, that’s true, but it does seem valuable to test it regardless.

test/parallel/test-strace-openat-openssl.js Outdated Show resolved Hide resolved
@RafaelGSS RafaelGSS force-pushed the add-strace-openat-test branch from b94519d to 1208513 Compare Jan 9, 2023
t.js Outdated Show resolved Hide resolved
@bnoordhuis
Copy link
Member

AssertionError [ERR_ASSERTION]: /proc/self/cmdline is not in the list of allowed openat calls

I don't think you're going to be able to avoid this. Different versions of glibc open different files, to say nothing of other libcs.

If you want to go fancy, you could wait until right before the child process does require('crypto') and attach with strace -p <pid>; will involve syncing over an IPC channel.

Another issue you or someone else inevitably is going to run into is that strace won't work on locked down systems (sysctl kernel.yama.ptrace_scope > 1)

@RafaelGSS
Copy link
Member Author

I don't think you're going to be able to avoid this. Different versions of glibc open different files, to say nothing of other libcs.

What about skipping /proc/* fd?

Another issue you or someone else inevitably is going to run into is that strace won't work on locked down systems (sysctl kernel.yama.ptrace_scope > 1)

Well, we can also run it only on CI, so I assume it will work all the time.

@bnoordhuis
Copy link
Member

What about skipping /proc/* fd?

That won't be enough. glibc can for any number of reasons decide to open files in /etc, /proc, /sys, /lib, etc.

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 21, 2023
@RafaelGSS
Copy link
Member Author

Requesting CI just to see how many use cases I would need to cover. Another viable option would be just logging it before publishing a release, however, it would require an extra step for a releaser, which is, definitely something I don't want.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 21, 2023
@nodejs-github-bot
Copy link
Contributor

Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
@RafaelGSS
Copy link
Member Author

What about skipping /proc/* fd?

That won't be enough. glibc can for any number of reasons decide to open files in /etc, /proc, /sys, /lib, etc.

Wouldn't it be consistent in the CI machine at least? Well, I think we won't have a better way to pursue this work, right?

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 31, 2023
@nodejs-github-bot
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants
X Tutup