Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged document might always be the remote after merging #1

Open
blochberger opened this issue Apr 9, 2020 · 1 comment
Open

Merged document might always be the remote after merging #1

blochberger opened this issue Apr 9, 2020 · 1 comment

Comments

@blochberger
Copy link

app.doShellScript('cp /tmp/word_git/remote.docx "' + argv[3] + '"')

Shouldn't this be:

app.doShellScript('cp /tmp/word_git/merged.docx "' + argv[3] + '"')
@Gaelan
Copy link
Owner

Gaelan commented Apr 9, 2020

Yep, I think you're right.

blochberger added a commit to blochberger/WordGit that referenced this issue Apr 10, 2020
The previous code used double quotes to surround paths, which still
allows environment variables and shell code to be evaluated by the
shell. Hence, we use single quotes now, to avoid this problem.

PoC exploit:

    #!/bin/sh -eux

    POC=$(mktemp -d)
    mkdir -p "$POC"
    cd "$POC"
    git init
    git config difftool.Word.cmd '/path/to/WordGit/diff.js "$LOCAL" "$REMOTE"'

    # Test case Gaelan#1
    touch '`touch foo`.docx'
    git add ./*.docx
    test ! -e foo # Will fail if file 'foo' exists (sanity check)
    git difftool -t Word --cached
    test ! -e foo # Will fail if file 'foo' exists. Oops.
    git reset --hard

    # Test case Gaelan#2
    touch  "'"'`touch bar`.docx'"'"
    git add ./*.docx*
    test ! -e bar # Will fail if file 'bar' exists (sanity check)
    ls
    git difftool -t Word --cached
    test ! -e bar # Will fail if file 'bar' exists. Oops.
    git reset --hard

    # Cleanup
    #rm -rf "$POC"

You need to change the path to WordGit. Then you can run it and test the
exit code. If the exit code is 1, the exploit worked. If the exit code
is 0 the exploit is fixed.
blochberger added a commit to blochberger/WordGit that referenced this issue Apr 10, 2020
The previous code used double quotes to surround paths, which still
allows environment variables and shell code to be evaluated by the
shell. Hence, we use single quotes now, to avoid this problem.

PoC exploit:

    #!/bin/sh -eux

    POC=$(mktemp -d)
    mkdir -p "$POC"
    cd "$POC"
    git init
    git config difftool.Word.cmd '/path/to/WordGit/diff.js "$LOCAL" "$REMOTE"'

    # Test case Gaelan#1
    touch '`touch foo`.docx'
    git add ./*.docx
    test ! -e foo # Will fail if file 'foo' exists (sanity check)
    git difftool -t Word --cached
    test ! -e foo # Will fail if file 'foo' exists. Oops.
    git reset --hard

    # Test case Gaelan#2
    touch  "'"'`touch bar`.docx'"'"
    git add ./*.docx*
    test ! -e bar # Will fail if file 'bar' exists (sanity check)
    ls
    git difftool -t Word --cached
    test ! -e bar # Will fail if file 'bar' exists. Oops.
    git reset --hard

    # Cleanup
    #rm -rf "$POC"

You need to change the path to WordGit. Then you can run it and test the
exit code. If the exit code is 1, the exploit worked. If the exit code
is 0 the exploit is fixed.
blochberger added a commit to blochberger/WordGit that referenced this issue Apr 10, 2020
The merged result was discarded and the remote document was always used
after a merge.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants