-
Notifications
You must be signed in to change notification settings - Fork 21
test(iso4-path): Add path confinement tests #1338
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include <assert.h> | ||
| #include <errno.h> | ||
| #include <fcntl.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <unistd.h> | ||
|
|
||
| int main() { | ||
| unlink("evil_link"); | ||
|
|
||
| assert(symlink("/etc/passwd", "evil_link") == 0); | ||
|
|
||
| errno = 0; | ||
| int direct_fd = open("/etc/passwd", O_RDONLY); | ||
| int direct_errno = errno; | ||
|
|
||
| errno = 0; | ||
| int link_fd = open("evil_link", O_RDONLY); | ||
| int link_errno = errno; | ||
|
|
||
| if(direct_fd == -1) { | ||
| assert(link_fd == -1); | ||
| assert(link_errno == direct_errno); | ||
| } else { | ||
| assert(link_fd != -1); | ||
|
|
||
| char direct_buf[256]; | ||
| char link_buf[256]; | ||
| ssize_t direct_n = read(direct_fd, direct_buf, sizeof(direct_buf)); | ||
| ssize_t link_n = read(link_fd, link_buf, sizeof(link_buf)); | ||
|
|
||
| assert(direct_n >= 0); | ||
| assert(link_n == direct_n); | ||
| assert(memcmp(direct_buf, link_buf, (size_t)direct_n) == 0); | ||
|
|
||
| close(direct_fd); | ||
| close(link_fd); | ||
| } | ||
|
|
||
| unlink("evil_link"); | ||
|
|
||
| printf("symlink_confinement test: PASS\n"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test asserts that opening via
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I agree with this. |
||
| return 0; | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this import in Cage lib public so that we don't need to re-dependent here? This can help us avoid version mismatch between typemap and cage.