Skip to content
Snippets Groups Projects
Commit 38821597 authored by Frédéric Dalleau's avatar Frédéric Dalleau :sun_with_face: Committed by Simon McVittie
Browse files

apparmor-ofono: open a root-owned file

ofono runs as root, so having the "malicious" LD_PRELOAD module read
/home/user/.bash_history requires it to exercise CAP_DAC_OVERRIDE,
leading to an AppArmor denial that doesn't match what we expect. Try
to read /etc/shadow instead, and update the expected denials
accordingly.

With that change, there's no real need for the "malicious" code to use
GLib, so use stdio instead.

Apertis: https://phabricator.apertis.org/T1848



Signed-off-by: default avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Reviewed-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D4388
parent 70152d17
No related branches found
No related tags found
No related merge requests found
/* vim: set sts=4 sw=4 et :
/* vim:set et sw=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e2s:
*
* A small library that can be loaded using LD_PRELOAD to do malicious things
* to test whether apparmor works
*/
/* Easier for the build system */
#include "../common/function-malicious-override.c"
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
static void
do_malicious_stuff (void)
{
const char *filename = "/etc/shadow";
if (fopen (filename, "r") == NULL)
{
fprintf (stderr, "Unable to be malicious: %s -- SUCCESS\n",
strerror(errno));
}
else
{
fprintf (stderr, "Malicious code read contents of '%s' -- FAILURE\n",
filename);
/* Exit immediately if apparmor doesn't stop us. */
exit (EXIT_FAILURE);
}
}
gboolean
g_option_context_parse (GOptionContext *context,
......
......@@ -3,5 +3,5 @@ profile:/usr/sbin/ofonod
sdmode:REJECTING
denied_mask:r
operation:open
name:/home/user/.bash_history
name:/etc/shadow
request_mask:r
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment