Red Hat Bugzilla – Bug 772261
CVE-2012-0787 augeas: susceptible to mountpoint attack
Last modified: 2016-04-26 11:44:17 EDT
Augeas is a configuration management API that represents the contents of config
files as a tree in memory for editing, with the edits being written back to the
actual file. By default it loads files it understands in a large number of
standard system locations (/etc, /boot), but can also open files in a user
specified location ,.
It has two save modes of interest, "backup" that keeps the original in
PATH.augorig and "newfile" that leaves the file alone, but writes the edited
version to PATH.augnew. These can be set via the API  or --backup/--new with
augtool (CLI tool around the API).
A flaw was found in the current 0.10.0 version and most previous versions. It
requires that the directory containing the file to be edited is writable by
another user, so this needs the user to explicitly open a file in another
location or for a file in a default location to be in a group/world writable
This attack hinges on behaviour to support writing to a bind mount (ticket #32 gives some history  relating to oVirt?) when doing the
rename fails with EBUSY or EXDEV. Augeas instead opens the file and writes straight into it, see transform.c in clone_file when copy_if_rename_fails is set from transform_save.
In two of the three, copy_if_rename_fails is only set if the node /augeas/save/copy_if_rename_fails is created by the user to enable the behaviour . I think there are three ways to exploit this code.
1) with --backup
When creating PATH.augsave, copy_if_rename_fails is always set to 1. A bind mount of a single file (or FUSE, enabling non-privileged attacks?) at PATH.augsave would cause the file contents to be written to the bind mounted file.
2) with --new and /augeas/save/copy_if_rename_fails
As above, but create bind mount at PATH.augnew.
3) with --backup and /augeas/save/copy_if_rename_fails
Augeas first moves PATH to PATH.augsave for the backup, then renames PATH.augnew to PATH. There's a tiny window in which a bind mount could be created at PATH, so the file contents are written to the bind mounted file.
Assigned CVE internally and added to alias and title.
Created attachment 572544 [details]
proposed upstream fix #1
Adding proposed patch for review.
ACK. Committed proposed upstream fix as commit b8de6a8c
Upstream commit from 20120719:
This was fixed in 1.0.0 according to the changelog (http://augeas.net/news.html):
* prevent cross-mountpoint attacks via .augsave during saving, RedHat bug #772261, CVE-2012-0787
(In reply to Vincent Danen from comment #15)
> Upstream commit from 20120719:
Project moved to github, matching commit link there is:
This issue has been addressed in following products:
Red Hat Enterprise Linux 6
Via RHSA-2013:1537 https://rhn.redhat.com/errata/RHSA-2013-1537.html
Created augeas tracking bugs for this issue:
Affects: fedora-all [bug 1033395]
Affects: epel-4 [bug 1033396]
Affects: epel-5 [bug 1033397]