git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Repository Security

From
AMAndre Masella <andre@masella.no-ip.org>
Date
Jan 23, 2007, 13:23 UTC
Message-ID
<200701230823.16021.andre@masella.no-ip.org>
In-Reply-To
<20070122205304.GB29739@spearce.org>
Show 6 quoted lines
> > 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.

Show 6 quoted lines
> 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?

Show 5 quoted lines
> 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)
Previous: Shawn O. PearceNext: Martin Langhoff
Message 3 of 13 in “Repository Security”
  1. Andre MasellaJan 22, 2007
  2. Shawn O. PearceJan 22, 2007
  3. Andre MasellaJan 23, 2007
  4. Martin LanghoffJan 22, 2007
  5. Johannes SchindelinJan 23, 2007
  6. Andre MasellaJan 23, 2007
  7. Johannes SchindelinJan 23, 2007
  8. Andy ParkinsJan 23, 2007
  9. Jakub NarebskiJan 23, 2007
  10. Andre MasellaJan 23, 2007
  11. Johannes SchindelinJan 23, 2007
  12. Andreas EricssonJan 24, 2007
  13. Linus TorvaldsJan 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.