git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Masella <andre@masella.no-ip.org>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: Repository Security
Date: Tue, 23 Jan 2007 08:23:15 -0500	[thread overview]
Message-ID: <200701230823.16021.andre@masella.no-ip.org> (raw)
In-Reply-To: <20070122205304.GB29739@spearce.org>

> > As I understand it, none of the repository backends allow any per-user
> > per-branch access control. SSH and HTTP come the closest with the right
> > hooks, but since the repository is writeable by those users, there is
> > little to stop them from changing the repository directly.
>
> Yes.  But hooks cannot be run in the HTTP case, can they?

Err...yes. I don't know what I was thinking when I wrote that.

> However in the HTTP case we use WebDAV to update the remote 
> server, which means security controls in the WebDAV server are
> probably sufficient to prevent unauthorized object upload or ref updates.

Apache has fairly limited authorization when it comes to WebDAV. I can 
authenticate users, but then there is no easy way to determine if they should 
be allowed to modify a particular file and the underlying file system can't 
help because all the users are mapped to a single one. Controlling access to 
directories would require creating .htaccess files everywhere with a list of 
allowed users.

> In the SSH case I fixed it by installing git-receive-pack setuid
> to the repository owner.  I locally patched receive-pack.c so it
> disables hook execution if that particular hook isn't owned by the
> repository user (to prevent rogue users from running arbitrary things
> as the repository owner).  This way nobody can change anything in
> a repository except through git-receive-pack.

That is very clever.

> Rather draconian.  But in a corporate world with some strict legal
> requirements placed upon you by your contracts with your customers
> sometimes you do have to verify that Bob really is Bob, or at least
> knows Bob's password.

Even without the legal requirements, management may resist a system where a 
developer from one project can view, let alone modify, another project.

> > I could also make the HTTP less dumb, if I had a better idea what that
> > might involve. 
> The HTTP push client is dumb because it needs to send loose objects
> to the remote repository.

Okay. And HTTP is the only dumb protocol right now?

> A "smart" plugin to Apache is unnecessary I think.  A CGI which
> splits the main() method of git-receive-pack into two halves (one
> to write_head_info, the other to do the rest of the work) is all
> that is required here to make HTTP push smart.

I see. I wonder about building this into gitweb. Adding a little check of the 
User-Agent can make it decide if it is going to display pretty things or 
allow repository access.

> Then have the HTTP client make one GET request to obtain the head info,
> then a POST request to upload the pack to git-receive-pack.

This would break exisiting HTTP repositories though. Perhaps it should get a 
different name.

In recieve-pack, are the commands read in read_head_info (which would be the 
POST request) all unidirectional?

> Since the hooks are then running as the web server user, and inherit
> the entire HTTP environment, you can do authentication in the web
> server but do authorization from within the hook, where you have
> much finer control to inspect what is occurring.  And only the web
> server needs to have write access to the repository.

All of which is fairly easy to do.
-- 
--Andre Masella (andre at masella.no-ip.org)

  reply	other threads:[~2007-01-23 13:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-22 19:33 Repository Security Andre Masella
2007-01-22 20:53 ` Shawn O. Pearce
2007-01-23 13:23   ` Andre Masella [this message]
2007-01-22 23:46 ` Martin Langhoff
2007-01-23  9:41 ` Johannes Schindelin
2007-01-23 13:23   ` Andre Masella
2007-01-23 14:29     ` Johannes Schindelin
2007-01-23 15:00     ` Andy Parkins
2007-01-23 11:06 ` Jakub Narebski
2007-01-23 13:23   ` Andre Masella
2007-01-23 21:38     ` Johannes Schindelin
2007-01-24  9:31     ` Andreas Ericsson
2007-01-23 16:18   ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200701230823.16021.andre@masella.no-ip.org \
    --to=andre@masella.no-ip.org \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).