1. Yes and no. Ideally we would have a aa_query function that accepted
an open file descriptor. That isn't available right now but should be
down the road.

access(2) is more racey, IMO, because unprivileged attackers can modify
file permissions and fool programs doing the access() -> open() dance.
Passing a path to aa_query_label() is not entirely susceptible to the
TOCTOU conditions known with access(2) because only a privileged user
can load AppArmor profiles.

2. symlinks are a problem with this interface since the kernel isn't
actually walking the path. Instead, the kernel is just using the path
string passed to it in order to look up the set of allowed permissions.

This means that you'll need to fully resolve a symlink target and pass
it to aa_query_label(). That also opens up the chance of another race
condition. If the symlink file is user controllable, an attacker might
make the symlink point to an innocent path, let a trusted helper resolve
the innocent path and call aa_query_label(), and then win the race to
adjust the symlink to point to a malicious path before the trusted
helper calls open().

If the paths that you're performing queries on are not user
controllable, I think you should be safe using aa_query_label(). If they
are user controllable, you'll probably need to wait until we have an
interface that accepts an open fd.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to apparmor in Ubuntu.
https://bugs.launchpad.net/bugs/1381713

Title:
  Support policy query interface for file

Status in AppArmor Linux application security framework:
  Triaged
Status in Media Hub:
  New
Status in Media Scanner v2:
  New
Status in Thumbnail generator for all kinds of files:
  New
Status in apparmor package in Ubuntu:
  Fix Released

Bug description:
  This bug tracks the work needed to support querying if a label can
  access a file. This is particularly useful with trusted helpers where
  an application requests access to a file and the trusted helper does
  something with it. For example, on Ubuntu when an app wants to play a
  music file, it (eventually) goes through the media-hub service. The
  media-hub service should be able to query if the app's policy has
  access to the file.

To manage notifications about this bug go to:
https://bugs.launchpad.net/apparmor/+bug/1381713/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to