Changeset cf4b7f4


Ignore:
Timestamp:
Sep 15, 2012, 10:51:23 PM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
0f60d8b
Parents:
08d4fa6
git-author:
Alex Dehnert <adehnert@…> (09/15/12 22:51:23)
git-committer:
Alex Dehnert <adehnert@…> (09/15/12 22:51:23)
Message:

Use a new PAG for accessing constitutions

This fixes a potential privilege escalation issue from asa-internal (or anybody
else who can read constitutions) to asa-db-root. In particular, by putting a
path within the asa-db locker in for their constitution, they could convince
the DB to copy /mit/asa-db/.my.cnf or other sensitive files into the
constitutions directory, and then read it. By creating a new PAG, we drop the
daemon.scripts privileges and prevent the attack.

In a future change, we may wish to aklog with a new principal so as to be able
to read non-public constitutions. When we do so, we should be careful not to
use daemon.asa-db or any other principal with privileged read access to AFS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/models.py

    r3113644 rcf4b7f4  
    1111import re
    1212import shutil
     13import subprocess
    1314import urlparse
    1415import urllib
     
    169170                new_mimetype = None
    170171                if url.startswith('/afs/') or url.startswith('/mit/'):
    171                     new_fp = open(url, 'rb')
     172                    new_data = mit.pag_check_output(['/bin/cat', url], aklog=False, stderr=subprocess.STDOUT)
    172173                else:
    173174                    new_fp = urllib2.urlopen(url)
    174175                    if new_fp.info().getheader('Content-Type'):
    175176                        new_mimetype = new_fp.info().gettype()
    176 
    177                 new_data = new_fp.read()
    178                 new_fp.close()
     177                    new_data = new_fp.read()
     178                    new_fp.close()
    179179            except urllib2.HTTPError, e:
    180180                error_msg = "HTTPError: %s %s" % (e.code, e.msg)
    181181            except urllib2.URLError, e:
    182182                error_msg = "URLError: %s" % (e.reason)
     183            except subprocess.CalledProcessError, e:
     184                results = e.output.split(": ")
     185                if len(results) == 3 and results[0] == '/bin/cat' and results[1] == url:
     186                    cat_err = results[2]
     187                else:
     188                    cat_err = e.output
     189                error_msg = "CalledProcessError %d: %s" % (e.returncode, cat_err)
    183190            except IOError:
    184191                error_msg = "IOError"
Note: See TracChangeset for help on using the changeset viewer.