forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed fetch traversal from slurp (ansible#68720)
* fixed fetch traversal from slurp * ignore slurp result for dest * fixed naming when source is relative * fixed bug in local connection plugin * added tests with fake slurp * moved existing role tests into runme.sh * normalized on action excepts * moved dest transform down to when needed * added is_subpath check * fixed bug in local connection fixes ansible#67793 CVE-2019-3828 (cherry picked from commit ba87c22)
- Loading branch information
Showing
12 changed files
with
121 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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,2 @@ | ||
bugfixes: | ||
- In fetch action, avoid using slurp return to set up dest, also ensure no dir traversal CVE-2019-3828. |
This file contains 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 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 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 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
shippable/posix/group2 | ||
needs/target/setup_remote_tmp_dir |
26 changes: 26 additions & 0 deletions
26
test/integration/targets/fetch/injection/avoid_slurp_return.yml
This file contains 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,26 @@ | ||
- name: ensure that 'fake slurp' does not poison fetch source | ||
hosts: localhost | ||
gather_facts: False | ||
tasks: | ||
- name: fetch with relative source path | ||
fetch: src=../injection/here.txt dest={{output_dir}} | ||
become: true | ||
register: islurp | ||
|
||
- name: fetch with normal source path | ||
fetch: src=here.txt dest={{output_dir}} | ||
become: true | ||
register: islurp2 | ||
|
||
- name: ensure all is good in hollywood | ||
assert: | ||
that: | ||
- "'..' not in islurp['dest']" | ||
- "'..' not in islurp2['dest']" | ||
- "'foo' not in islurp['dest']" | ||
- "'foo' not in islurp2['dest']" | ||
|
||
- name: try to trip dest anyways | ||
fetch: src=../injection/here.txt dest={{output_dir}} | ||
become: true | ||
register: islurp2 |
This file contains 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 @@ | ||
this is a test file |
This file contains 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,29 @@ | ||
#!/usr/bin/python | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
|
||
DOCUMENTATION = """ | ||
module: fakeslurp | ||
short_desciptoin: fake slurp module | ||
description: | ||
- this is a fake slurp module | ||
options: | ||
_notreal: | ||
description: really not a real slurp | ||
author: | ||
- me | ||
""" | ||
|
||
import json | ||
import random | ||
|
||
bad_responses = ['../foo', '../../foo', '../../../foo', '/../../../foo', '/../foo', '//..//foo', '..//..//foo'] | ||
|
||
|
||
def main(): | ||
print(json.dumps(dict(changed=False, content='', encoding='base64', source=random.choice(bad_responses)))) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
1 change: 0 additions & 1 deletion
1
test/integration/targets/fetch/meta/main.yml → ...ets/fetch/roles/fetch_tests/meta/main.yml
This file contains 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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
dependencies: | ||
- prepare_tests | ||
- setup_remote_tmp_dir |
File renamed without changes.
This file contains 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,5 @@ | ||
- name: call fetch_tests role | ||
hosts: testhost | ||
gather_facts: false | ||
roles: | ||
- fetch_tests |
This file contains 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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
# setup required roles | ||
ln -s ../../setup_remote_tmp_dir roles/setup_remote_tmp_dir | ||
|
||
# run old type role tests | ||
ansible-playbook -i ../../inventory run_fetch_tests.yml -e "output_dir=${OUTPUT_DIR}" -v "$@" | ||
|
||
# run tests to avoid path injection from slurp when fetch uses become | ||
ansible-playbook -i ../../inventory injection/avoid_slurp_return.yml -e "output_dir=${OUTPUT_DIR}" -v "$@" |