-
-
Notifications
You must be signed in to change notification settings - Fork 598
syscall: follow trusted sender ancestor links #1088
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
Open
steadytao
wants to merge
7
commits into
master
Choose a base branch
from
sender-ancestor-links
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec94434
syscall: follow trusted sender ancestor links
steadytao 918ff43
testsuite: accept BSD symlink errors
steadytao d0a5ab7
syscall: anchor sender paths at explicit source roots
steadytao 0286b78
flist: pin explicit file source parents
steadytao c9f8e21
flist: preserve search-only source traversal
steadytao e7a4014
sender: follow trusted files-from ancestors
steadytao 4f6d572
sender: enforce files-from symlink ownership
steadytao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env python3 | ||
| """Absolute --relative sources with a trusted-owned ancestor symlink.""" | ||
|
|
||
| import os | ||
| import pwd | ||
| import subprocess | ||
|
|
||
| from rsyncfns import SCRATCHDIR, rsync_argv, test_fail | ||
|
|
||
| real = SCRATCHDIR / 'real' | ||
| source = real / 'My_Documents' | ||
| source.mkdir(parents=True) | ||
| (source / 'marker').write_text('source contents\n') | ||
| link = SCRATCHDIR / 'home' | ||
| os.symlink(str(real), link) | ||
|
|
||
| for index, options in enumerate((('-a',), ('-aR',), ('-aR', '--no-inc-recursive'))): | ||
| for trailing in ('', '/'): | ||
| dest = SCRATCHDIR / f'dest-{index}-{bool(trailing)}' | ||
| dest.mkdir() | ||
| proc = subprocess.run( | ||
| rsync_argv(*options, str(link / 'My_Documents') + trailing, str(dest) + '/'), | ||
| capture_output=True, text=True, | ||
| ) | ||
| if proc.returncode: | ||
| test_fail(f'trusted ancestor transfer failed: {proc.stdout}{proc.stderr}') | ||
| if '-aR' in options: | ||
| expected = dest / str(link / 'My_Documents').lstrip('/') / 'marker' | ||
| else: | ||
| expected = dest / ('' if trailing else 'My_Documents') / 'marker' | ||
| if not expected.is_file() or expected.read_text() != 'source contents\n': | ||
| test_fail('relative source layout or contents changed') | ||
|
|
||
| dest = SCRATCHDIR / 'remove-dest' | ||
| dest.mkdir() | ||
| proc = subprocess.run( | ||
| rsync_argv('-aR', '--remove-source-files', str(link / 'My_Documents') + '/', str(dest) + '/'), | ||
| capture_output=True, text=True, | ||
| ) | ||
| expected = dest / str(link / 'My_Documents').lstrip('/') / 'marker' | ||
| if proc.returncode or (source / 'marker').exists() or not expected.is_file(): | ||
| test_fail(f'remove-source-files failed: {proc.stdout}{proc.stderr}') | ||
| (source / 'marker').write_text('source contents\n') | ||
|
|
||
| if os.geteuid() == 0: | ||
| attacker = next((entry.pw_uid for entry in pwd.getpwall() if entry.pw_uid != 0), None) | ||
| if attacker is not None: | ||
| os.lchown(link, attacker, -1) | ||
| dest = SCRATCHDIR / 'untrusted-dest' | ||
| dest.mkdir() | ||
| proc = subprocess.run( | ||
| rsync_argv('-aR', str(link / 'My_Documents') + '/', str(dest) + '/'), | ||
| capture_output=True, text=True, | ||
| ) | ||
| if proc.returncode == 0 or any(dest.rglob('marker')): | ||
| test_fail('an untrusted ancestor symlink was followed') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.