Generating a profile

aa-genprof and aa-autodep for application developers for administrators

One recorded aa-genprof session that takes a program from no profile to enforce mode. What the tool does before its first question - the starter profile and complain mode and the log mark. The Scan and Finish loop. The exec question and the rule each key writes. Reading the profile the tool wrote. aa-autodep and scripts and the programs the tools refuse to profile.

On the map: tools

▶ Watch this deck — 9 scenes, ~7 min

Worth seeing first

Part of journeys

01 From no profile to enforce, in one sitting

aa-genprof demo no profile yet # aa-genprof /usr/bin/demo a tiny profile complain mode: nothing blocked, all logged you run demo the log (S)can: questions rules again, until a scan asks nothing (F)inish the profile goes to enforce mode one real session follows, key by key, with two wrong suggestions
The profiling loop: aa-genprof writes a small profile for demo and sets it to complain mode; you run demo; the kernel logs what the profile lacks; Scan turns each record into a question; answers become rules; Finish sets enforce mode.

aa-genprof PROGRAM creates a starter profile in complain mode, then loops: you run the program, (S)can turns the new log records into questions, your answers become rules. (F)inish sets enforce mode. The deck follows one recorded session.

Demo has no profile. You could write one by hand, and the syntax decks show how. Or you can let demo show you what it needs. That's aa-genprof. You give it the program. It writes a tiny profile and switches it to complain mode, where nothing is blocked and everything missing is logged. You run demo and use it. The tool reads the log and asks you one question per thing demo did. Your answers become rules. When you're done, it switches the profile to enforce. This deck follows one real session with demo, key by key, including two places where the tool's suggestion was wrong.

Details and sources

Details

  • aa-genprof [-d DIR] [-f LOGFILE] [--no-abstraction] [-o OUTDIR] program. Run it as root: it writes into the profile directory, loads profiles and reads the audit log.
  • The program is demo (/usr/bin/demo), the map's example: it reads /etc/demo/demo.conf, looks up a user, reads a word list under /usr/share/demo, writes /var/lib/demo/state.db and /var/log/demo.log, makes a temporary file, opens a TCP connection, raises its priority and runs /usr/bin/demo-helper.
  • The session: one exec question, ten rule questions for demo, three for the helper's profile, one save prompt, then Finish.
  • Complain mode: an access the profile does not allow goes through and is logged with apparmor="ALLOWED". Explicit deny rules are still enforced in complain mode.
  • aa-logprof asks the same questions without the loop, for every profile at once. See aa-logprof.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

for AppArmor developers

Code

02 What aa-genprof does first

BEFORE THE FIRST QUESTION # aa-genprof /usr/bin/demo Writing updated profile for /usr/bin/demo. Setting /usr/bin/demo to complain mode. 1 not on the list of programs that get no profile abi <abi/5.0>, include <tunables/global> /usr/bin/demo flags=(complain) { include <abstractions/base> /usr/bin/demo mr, } 2 the starter profile what aa-autodep writes 3 complain mode, loaded 4 log rate limit off; the end of the log is noted Profiling: /usr/bin/demo Please start the application to be profiled in another window and exercise its functionality now. ... [(S)can system log for AppArmor events] / (F)inish
aa-genprof /usr/bin/demo prints that it writes a profile and sets it to complain mode. The starter profile has abi, tunables/global, abstractions/base and the binary with mr. Then the Scan or Finish prompt.

Before the first question aa-genprof checks the program against logprof.conf, writes a starter profile (abstractions/base and mr on the binary) in complain mode, loads it, sets kernel.printk_ratelimit to 0 and marks the end of the log.

Start it as root with the program's path. Before it asks anything, aa-genprof does four things. It checks that demo isn't on a list of programs that shouldn't get their own profile. It writes a first profile, the same one aa-autodep would write: the base abstraction, plus read and map for the binary itself. It sets that profile to complain mode and loads it. And it turns off the kernel's rate limit for log messages, so no event is dropped, and notes where the log ends right now. Then it waits, with one line to choose from: scan, or finish.

Details and sources

Details

  • The program name is looked up in PATH when it has no slash. Errors: Can't find NAME in the system path list..., NAME does not exists, please double-check the path.
  • A profile is created only when none exists for the program. An existing profile is kept and put into complain mode.
  • The starter profile: flags=(complain), include <abstractions/base>, and /usr/bin/demo mr,; abi <abi/5.0>, and include <tunables/global> are added when those files exist in the profile directory. The file is named after the path, /etc/apparmor.d/usr.bin.demo, and the profile has the path as its name, without the profile keyword.
  • The profile text on the slide is put together from the tool's code and from the starter profile observed for a script (scene "aa-autodep, scripts and programs the tools refuse"); the session itself printed only the two message lines.
  • /proc/sys/kernel/printk_ratelimit is set to 0 so that bursts of records are not dropped, and restored when the tool exits. When that fails: Can't set printk_ratelimit, some events might be lost.
  • The log mark: with /var/log/audit/audit.log present the tool notes the time of the last audit record; otherwise it writes a line GenProf: logmark-<time> to the kernel log with logger and scans from there.
  • It also prints a paragraph that suggests checking the wiki for an existing profile.
  • Error when AppArmor is not running: It seems AppArmor was not started. Please enable AppArmor and try again.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

for AppArmor developers

Code

03 Run the program, then press S

RUN, THEN SCAN $ demo demo-helper: done demo: done another window: use every feature a feature you skip is a rule you do not get complain mode: it all works, and each missing permission is logged apparmor="ALLOWED" operation="open" profile="/usr/bin/demo" name="/etc/demo/demo.conf" requested_mask="r" fsuid=0 ouid=0 apparmor="ALLOWED" operation="capable" ... capname="sys_nice" apparmor="ALLOWED" operation="exec" ... name="/usr/bin/demo-helper" [(S)can system log for AppArmor events] / (F)inish Reading log entries from /var/log/audit/audit.log. press S records the profile already covers are dropped exec questions come first: the answer decides which profile the helper's own records belong to
Two windows. In one, demo runs and finishes normally. The kernel logs records with apparmor="ALLOWED" for everything the starter profile lacks. In the other, pressing S makes aa-genprof read the log from its mark.

While the profile is in complain mode the program runs normally and every missing permission is logged as apparmor="ALLOWED". (S)can reads the log from the mark, skips what the profile covers and asks about the rest, exec events first.

Now go to another window and use demo. Really use it: every feature you skip is a rule you won't get. Demo reads its config, looks up a user, writes its state and its log, opens a network connection and starts a helper. In complain mode all of that works, and each thing the profile doesn't allow leaves a log record marked allowed. Back in the first window, press S. The tool reads the log from the point it noted, drops what the profile already covers, and starts asking. Exec questions come first, because the answer decides which profile the helper's own events belong to.

Details and sources

Details

  • Records from the session (pid removed): apparmor="ALLOWED" operation="open" class="file" profile="/usr/bin/demo" name="/etc/demo/demo.conf" comm="demo" requested_mask="r" denied_mask="r" fsuid=0 ouid=0; apparmor="ALLOWED" operation="capable" class="cap" profile="/usr/bin/demo" comm="demo" capability=23 capname="sys_nice"; apparmor="ALLOWED" operation="exec" class="file" profile="/usr/bin/demo" name="/usr/bin/demo-helper" comm="demo" requested_mask="x" denied_mask="x" fsuid=0 ouid=0 target="/usr/bin/demo//null-/usr/bin/demo-helper". The slide shortens them.
  • Sixteen such records came from one run of demo; several records about one path are merged into one question.
  • The exec record names a target /usr/bin/demo//null-/usr/bin/demo-helper: in complain mode the kernel runs a program the profile has no exec rule for under a temporary profile and logs its accesses under that name. The tool assigns those records to a real profile after you answer the exec question.
  • The order of a scan: exec events, hat requests, then for each profile the other rule classes, complain-mode records before enforce-mode records, then the save prompt.
  • Only what ran between the mark and the scan is in the log. Start-up, every option, error paths and shutdown each need to happen at least once.
  • A scan with nothing new prints Complain-mode changes: and Enforce-mode changes: and returns to the prompt.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

Read more

for AppArmor developers

Code

04 First question: the helper

FIRST QUESTION: THE HELPER Profile: /usr/bin/demo Execute: /usr/bin/demo-helper Severity: unknown In(h)erit / (C)hild / (P)rofile / (N)amed / (U)nconfined / (X) ix On / (D)eny / Abo(r)t / (I)gnore / (F)inish H /usr/bin/demo-helper ix, the helper runs under demo's profile P ... Px, a profile of its own C ... Cx, a child profile in demo U ... Ux, unconfined, two warnings <P> Should AppArmor enable secure-execution mode when switching profiles? [(Y)es] / (N)o <Y> Adding /usr/bin/demo-helper Px, to profile. Writing updated profile for /usr/bin/demo-helper. a new profile, in complain mode the helper's records become its questions, in this same scan
The exec question for /usr/bin/demo-helper with its row of keys. Each key writes a rule: Inherit ix, Profile Px, Child Cx, Named an arrow rule, Unconfined Ux, Deny a deny rule. P then Yes writes Px and creates a profile for the helper.

An exec record becomes a choice of exec mode: In(h)erit writes ix, (P)rofile px, (C)hild cx, (N)amed an arrow rule, (U)nconfined ux, (D)eny a deny rule. Answering yes to secure execution capitalises the letter. Choosing a profile that does not exist creates it.

The first question is about the helper demo started. Each key is an exec mode. H, inherit, runs the helper under demo's own profile. P gives it a profile of its own. C makes a child profile inside demo's. The key U runs it unconfined, and the tool warns you twice. We press P. The tool asks whether to enable secure execution, we say yes, and the rule is written with a capital P. Since the helper has no profile yet, the tool creates one on the spot, in complain mode. From here on, the helper's log records turn into questions for that new profile, in this same scan.

Details and sources

Details

Keys of the exec question and what each writes into the profile of the program that ran the exec:

KeyRule writtenThen
H, In(h)erit/usr/bin/demo-helper ix, (with mr)the helper's records are asked about under the caller's profile
P, (P)rofile/usr/bin/demo-helper px,; Px after yes to secure executiona profile for the helper is created in complain mode if none exists
C, (C)hildcx or Cxa child profile is created inside the caller's profile
N, (N)amedasks "Are you specifying a transition to a local profile?" and "Enter profile name to transition to: "; writes px -> NAME or cx -> NAME
U, (U)nconfinedafter two warnings ux, or Uxthe helper's records are ignored
X, (X) ix On / Offswitches the list to the fallback modes pix, cix
D, (D)enydeny /usr/bin/demo-helper x,the helper's records are ignored
I, (I)gnorenothingasked again at the next scan
  • The secure-execution question in full: "Should AppArmor enable secure-execution mode when switching profiles? Doing so is more secure, but some applications depend on the presence of LD_PRELOAD or LD_LIBRARY_PATH, which would be sanitized by enabling secure-execution mode." Its default is yes. See safe and unsafe exec.
  • No key of the exec question is bracketed, so Return selects nothing and the question is shown again.
  • Which keys appear depends on [qualifiers] in logprof.conf: for shells the list has no (P)rofile, for core utilities such as cat neither (P)rofile nor (U)nconfined.
  • Severity: is a number from severity.db for the path with x, or unknown.
  • Session lines after P and Y: Adding /usr/bin/demo-helper Px, to profile. and Writing updated profile for /usr/bin/demo-helper.
  • Known discrepancy: a child profile created with (C)hild stays in complain mode after Finish; aa-logprof --allow-all answers the secure-execution question with no and writes lowercase px.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

for AppArmor developers

Code

05 Ten questions about demo

TEN QUESTIONS ABOUT demo Profile: /usr/bin/demo Capability: sys_nice Severity: 8 [1 - capability sys_nice,] (A)llow / [(D)eny] / (I)gnore / Audi(t) / Abo(r)t / (F)inish the default is Deny, also in complain mode Return writes a deny rule A allows · D denies Path: /tmp/demo.22t5Sb New Mode: owner rw [1 - include <abstractions/user-tmp>] 2 - owner /tmp/demo.22t5Sb rw, A: the abstraction, fine Network Family: inet Socket Type: stream [1 - include <abstractions/apache2-common>] 2 - include <abstractions/nameservice> 3 - network (connect) inet stream peer=(ip=127.0.0.1 port=9), offers are sorted by name press 3, then A we missed that on the second network question: see the result
Three rule questions from the session. The capability question with Deny bracketed as the default. The temporary file with the user-tmp abstraction offered first. The network connection with an Apache abstraction offered first, because offers are sorted by name.

Every rule question lists offers and keys. The bracketed default was (D)eny for every question of the session, so Return writes a deny rule; A allows the selected offer. Offers are sorted by name with the first selected: a digit picks another one.

Then the rules. Each question shows what demo did and offers one or more rules. Watch the brackets. The preselected answer is deny, even here in complain mode, so return writes a deny rule. Press A to allow. For the priority change we do press D: demo doesn't need it. For the temp file, the first offer is the user-tmp abstraction, and that's fine. For the network connection, the first offer is an Apache abstraction, simply because offers are sorted by name. Press 3 to pick the exact rule, then A. We missed that on the second network question, and you'll see it in the result.

Details and sources

Details

  • The ten rule questions for demo in the session, in order: capability sys_nice (answered D: deny capability sys_nice,), /tmp/demo.22t5Sb (A on include <abstractions/user-tmp>), /var/log/demo.log (O then A: /var/log/demo.log w,), /var/lib/demo/state.db (A), /usr/share/demo/words-1.txt (G then A: owner /usr/share/demo/* r,), /etc/passwd, /etc/nsswitch.conf, /etc/demo/demo.conf (A each), the connect event (3 then A), the socket create event (A on the selected offer, the Apache abstraction).
  • The default. The code sets the default to Allow for complain-mode records and Deny for enforce-mode records. In the session every question under "Complain-mode changes:" showed (A)llow / [(D)eny]. Known discrepancy: the comparison that should select Allow never matches. Do not press Return to accept. With an include offer selected, Deny writes nothing: the tool prints "Denying via an include file isn't supported by the AppArmor tools" and asks again.
  • Offers: abstractions that have a rule covering the record, sorted by name, then the exact rule. For a file there can also be paths of existing rules and ready-made globs. The first offer is selected; a digit or the arrow keys select another.
  • abstractions/apache2-common is offered for any inet or inet6 stream socket: it contains network inet stream,. It also allows being traced, signals from Apache's profiles and everything in abstractions/nameservice.
  • The network question's headers in full: Accesses: connect, Network Family: inet, Socket Type: stream, Local: ALL, Peer: {'ip': '127.0.0.1', 'port': 9}. The slide shows two of them on one line and wraps the long offer.
  • The key row is one line in the terminal; file questions add (G)lob / Glob with (E)xtension / (N)ew and (O)wner permissions off. Each key is explained in aa-logprof.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

Read more

for AppArmor developers

Code

06 Read what you answered

READ WHAT YOU ANSWERED /usr/bin/demo { include <abstractions/apache2-common> include <abstractions/base> include <abstractions/user-tmp> deny capability sys_nice, network (connect) inet stream peer=(ip=127.0.0.1 port=9), /usr/bin/demo mr, /usr/bin/demo-helper Px, /var/log/demo.log w, owner /etc/demo/demo.conf r, owner /etc/nsswitch.conf r, owner /etc/passwd r, owner /usr/share/demo/* r, owner /var/lib/demo/state.db w, } one careless A ptrace and signal rules demo has no use for: delete the line owner: profiled as root on root's files; another user is not the owner one exact path per file: precise, and breaks when a second file appears a first draft: the tool does not judge it for you
The profile file aa-genprof wrote for demo: three includes, a deny capability rule, a network rule, and file rules, most with owner. Three things to review: the Apache abstraction, the owner qualifiers, and how exact the paths are.

The saved profile holds exactly what was answered: an unrelated abstraction from one accepted offer, owner on files because the session ran as their owner, and exact paths. The file is written sorted, with the path as the profile name. Review it before relying on it.

S to save, and here's the file the tool wrote, rules sorted. Now read it like a reviewer. The Apache abstraction is in there: one careless A. It brings ptrace and signal rules demo has no use for, so delete that line. Most file rules say owner, because we ran demo as root on root's files, and the log showed the user and the file's owner matched. Run demo as another user and those rules stop matching. And the config directory got one exact path per file. None of this is wrong syntax. It's a first draft, and the tool doesn't judge it for you.

Details and sources

Details

The file as written after the first save (/etc/apparmor.d/usr.bin.demo on an installed system; the slide leaves out the first four lines and the blank lines):

# Last Modified: Mon Nov 16 12:26:18 2026 abi <abi/5.0>,

include <tunables/global>

/usr/bin/demo { include <abstractions/apache2-common> include <abstractions/base> include <abstractions/user-tmp>

deny capability sys_nice,

network (connect) inet stream peer=(ip=127.0.0.1 port=9),

/usr/bin/demo mr, /usr/bin/demo-helper Px, /var/log/demo.log w, owner /etc/demo/demo.conf r, owner /etc/nsswitch.conf r, owner /etc/passwd r, owner /usr/share/demo/* r, owner /var/lib/demo/state.db w,

}

  • flags=(complain) is gone from this listing because it was taken after Finish; during the session the profile carries it.
  • include <abstractions/apache2-common> came from accepting the selected offer of the socket create question. It grants network inet stream, and network inet6 stream,, ptrace (readby) and ptrace (tracedby), several signal rules and abstractions/nameservice. With it in place the exact network (connect) rule is redundant.
  • owner: the tool adds it when the record's fsuid equals its ouid. Seen later in the same guest: demo run by an ordinary user under this profile was denied /etc/demo/demo.conf, /usr/share/demo/words-1.txt and /var/lib/demo/state.db (fsuid=1000 ouid=0).
  • /etc/nsswitch.conf and /etc/passwd got their own rules. abstractions/nameservice covers both, but it was not offered for them. Known discrepancy: the tools do not expand variables such as @{etc_ro} when they test whether an abstraction covers a path.
  • deny capability sys_nice, is enforced silently: demo prints setpriority: Permission denied and nothing is logged.
  • New profile files are created with mode 0600. The profile for the helper was written the same way (usr.bin.demo-helper).
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

for AppArmor developers

Code

07 Finish, and what is still missing

FINISH [(S)can system log for AppArmor events] / (F)inish <F> Setting /usr/bin/demo to enforce mode. Setting /usr/bin/demo-helper to enforce mode. Reloaded AppArmor profiles in enforce mode. Finished generating profile for /usr/bin/demo. now the profile is the limit $ demo demo: done the way you ran it: works $ demo extra /etc/demo/extra.conf: Permission denied that code did not run while the tool was watching you do not start over aa-logprof same log, same questions, any profile, any time
After a scan with no questions, F sets the profiles of demo and demo-helper to enforce mode. demo run as before works. demo run with a new option is denied a file that was never opened during profiling. aa-logprof handles that later.

(F)inish sets every profile the session created to enforce mode and reloads it. What was not exercised has no rule: observed, a run with a new option is denied /etc/demo/extra.conf. aa-logprof adds such rules later without starting over.

Run demo again, scan again. When a scan comes back with no questions, press F. The tool sets demo's profile, and the helper's, to enforce mode and reloads them. Now the profile is the limit. Demo run the way you ran it works. But start demo with an option you didn't try, and it's denied its extra config file. That code didn't run while the tool was watching. That's normal, and you don't start over. You run aa-logprof, which reads the same log and asks the same kind of question, for any profile, at any time. It has its own deck.

Details and sources

Details

  • On Finish the tool sets each profile it created or put into complain mode back to enforce and reloads it with apparmor_parser -r. Messages: Setting /usr/bin/demo to enforce mode., Setting /usr/bin/demo-helper to enforce mode., Reloaded AppArmor profiles in enforce mode., a paragraph inviting you to contribute the profile, Finished generating profile for /usr/bin/demo.
  • The kernel's list of profiles afterwards: /usr/bin/demo (enforce), /usr/bin/demo-helper (enforce), and still /usr/bin/demo//null-/usr/bin/demo-helper (complain), the temporary profile from the first run. It is not used again and disappears when the profile is removed or the system restarts.
  • Under enforce, demo as profiled: setpriority: Permission denied (the deny capability sys_nice, answered with D; the program goes on), demo-helper: done, demo: done. The slide shows the last line only. demo extra: /etc/demo/extra.conf: Permission denied, with apparmor="DENIED" operation="open" class="file" profile="/usr/bin/demo" name="/etc/demo/extra.conf" comm="demo" requested_mask="r" denied_mask="r" fsuid=0 ouid=0.
  • A careful path to enforce for a service: keep the profile in complain mode for a while in real use (answer Finish, then aa-complain), run aa-logprof until it asks nothing, then aa-enforce.
  • Known discrepancy: child profiles created during the session are left in complain mode by Finish.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

Read more

for AppArmor developers

Code

08 aa-autodep, scripts and programs the tools refuse

aa-autodep · SCRIPTS · REFUSALS # aa-autodep /usr/bin/demo-script Writing updated profile for /usr/bin/demo-script. the first step of aa-genprof, on its own /usr/bin/demo-script flags=(complain) { include <abstractions/base> include <abstractions/bash> /usr/bin/dash ix, /usr/bin/demo-script r, } a script: read the script, run its interpreter with ix, the interpreter's abstraction # aa-genprof /usr/bin/cat /usr/bin/cat is currently marked as a program that should not have its own profile. ... shells and core utilities are listed in logprof.conf for those: write the exec rule in the caller's profile instead
aa-autodep writes only the starter profile. For a shell script it allows reading the script, running the interpreter with ix and includes the bash abstraction. aa-genprof refuses programs marked in logprof.conf, such as cat.

aa-autodep PROGRAM writes the starter profile and nothing more. For a script it allows the script with r, the interpreter with ix and adds the interpreter's abstraction. Programs marked in [qualifiers] of logprof.conf are refused. Observed.

Two smaller things. aa-autodep is the first step of aa-genprof on its own: it writes the starter profile in complain mode and stops. For a script, that profile allows reading the script and running its interpreter with ix, and it includes the interpreter's abstraction, as you see here for a shell script. And some programs are refused. The tool's config file lists shells and core utilities, like cat, as programs that shouldn't have their own profile, because confining them changes everything that calls them. Ask aa-genprof to profile cat and it stops with this message. For those, you write the rule in the caller's profile instead.

Details and sources

Details

  • aa-autodep [--force] [-d DIR] [--no-reload] program... writes the starter profile for each program that has none (--force overwrites) and loads it in complain mode.
  • For a script the first line decides: the interpreter after #! gets ix, the script itself r. The abstraction is abstractions/bash when the interpreter is sh, bash or dash, and abstractions/perl, abstractions/python or abstractions/ruby for those interpreters; any other interpreter gets none.
  • The profile written for /usr/bin/demo-script (#!/bin/sh) in the session, complete:

# Last Modified: Mon Nov 16 12:18:54 2026 abi <abi/5.0>,

include <tunables/global>

/usr/bin/demo-script flags=(complain) { include <abstractions/base> include <abstractions/bash>

/usr/bin/dash ix, /usr/bin/demo-script r,

}

  • /bin/sh was resolved to /usr/bin/dash: the rule names the file the symlink leads to. See Symlinks.
  • With ix the interpreter runs under the script's profile, so the profile must allow everything the script does through it.
  • Refusal, in full: "/usr/bin/cat is currently marked as a program that should not have its own profile. Usually, programs are marked this way if creating a profile for them is likely to break the rest of the system. If you know what you're doing and are certain you want to create a profile for this program, edit the corresponding entry in the [qualifiers] section in /etc/apparmor/logprof.conf." Exit status 1. In the session the message was preceded by three lines of a Python stack.
  • Marked programs include the shells (bash, dash, ksh, zsh), mount, utilities such as awk, cat, chmod, cp, grep, ls, sed, and the perl and python interpreters. A profile attached to /usr/bin/cat would apply to every unconfined use of cat.
  • If a profile with the same name exists among the inactive profiles (/usr/share/apparmor/extra-profiles), the tool offers to use it instead of the starter profile. Read from the tool's code, not run.
  • Observed on 2026-11-16: the tree's utils/ (aa-genprof, aa-logprof, aa-autodep and their Python package) and the tree's profiles/apparmor.d were run in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64; apparmor_parser and the Python binding of libapparmor 5.0.2 from Debian; auditd), as root. Keys were sent by a script on a terminal; the transcripts are findings/tools/observed/session1.txt and session2.txt. The slides quote session 2.

for AppArmor developers

Code

09 Where to go from here

ROADS aa-genprof: from nothing to enforce starter profile · complain · run · scan · answer · finish ut-logprof every part of a question prac-general-purpose how broad is fine prac-abstractions which offers to accept syn-exec-modes ix px cx ux syn-owner the owner qualifier also: ut-modes (aa-complain, aa-enforce) · adm-denials (the records) · syn-safe-unsafe syn-flags-modes · prac-privileged
Generating a profile in the centre, with roads to ut-logprof, prac-general-purpose, prac-abstractions, syn-exec-modes and syn-owner, and a row naming ut-modes, adm-denials, syn-safe-unsafe, syn-flags-modes and prac-privileged.

Next: ut-logprof, prac-general-purpose, prac-abstractions, syn-exec-modes, syn-owner, ut-modes, adm-denials.

That's a profile from nothing to enforce: a starter profile in complain mode, run, scan, answer, and finish. The tool writes down your answers, so the quality of the profile is the quality of the answers. Next, the aa-logprof deck takes one question apart, covers glob and owner, and lists where the suggestions go wrong. The deck on general-purpose apps helps you decide how broad a first profile may be, and the abstractions deck tells you which offers to accept. And the exec modes deck explains the letters behind that first question.

Details and sources

Details

  • aa-genprof PROGRAM: starter profile in complain mode, then run, (S)can, answer, save, repeat; (F)inish sets enforce mode.
  • The profile contains what was answered. Review the includes, the owner qualifiers and the width of the paths before relying on it.

What each deck answers:

Read more

Basis of the statements on this page: "observed" means the utilities of the AppArmor tree at 836052d21 (6.0.0~alpha2) were run on 2026-11-16 in a disposable Debian forky/sid guest (kernel 7.3.4+deb14-cloud-amd64, apparmor_parser and the libapparmor Python binding 5.0.2 from Debian, auditd), as root, with keys sent by a script; transcripts are in findings/tools/observed/. "Code" means read from the tree and not run.

Command lines

CommandDoes
aa-genprof [-d DIR] [-f LOGFILE] [-j] [--no-abstraction] [-o OUTDIR] programstarter profile if needed, complain mode, the Scan and Finish loop, enforce mode at the end
aa-autodep [--force] [-d DIR] [--no-reload] program...writes the starter profile in complain mode
OptionMeaning
-d DIRprofile directory instead of /etc/apparmor.d
-f LOGFILElog file to read
-jdialogs as JSON, for front ends
--no-abstractiondo not offer or add abstractions
-o OUTDIRwrite changed profiles to this directory instead

What aa-genprof does, in order

StepMessage or effectBasis
find the programerrors Can't find ... in the system path list or ... does not exists, please double-check the path.code
check [qualifiers]"... is currently marked as a program that should not have its own profile."observed
read all profilesUpdating AppArmor profiles in DIR.observed
starter profile if none existsWriting updated profile for PROGRAM.observed
complain mode and reloadSetting PROGRAM to complain mode.observed
kernel.printk_ratelimit = 0warning Can't set printk_ratelimit, some events might be lost on failurecode
mark the logtime of the last audit record, or a GenProf: logmark-... linecode
prompt[(S)can system log for AppArmor events] / (F)inishobserved
ScanReading log entries from FILE., exec questions, Complain-mode changes:, Enforce-mode changes:, save promptobserved
FinishSetting PROGRAM to enforce mode. for each profile of the session, Reloaded AppArmor profiles in enforce mode., Finished generating profile for PROGRAM.observed

The starter profile

Program isRules
a binaryinclude <abstractions/base>, PROGRAM mr,
a script with #!include <abstractions/base>, the interpreter's abstraction (bash, perl, python, ruby) when known, SCRIPT r,, INTERPRETER ix,

Always with flags=(complain); abi <abi/5.0>, and include <tunables/global> when those files exist in the profile directory. The profile is named by the program's path and stored as that path with slashes turned into dots.

The exec question

KeyRuleNotes
HTARGET ix,
PTARGET px, or Px,creates a profile for the target if none exists
CTARGET cx, or Cx,creates a child profile
Npx -> NAME or cx -> NAMEasks for the name
UTARGET ux, or Ux,two confirmations
Xtoggles pix / cix forms
Ddeny TARGET x,
Inothingasked again later
R, Fabort, finish

Capital letters result from answering yes to the secure-execution question. The letters offered for a target come from [qualifiers] in logprof.conf.

The session, question by question

QuestionKeyRule written
Execute /usr/bin/demo-helperP, Y/usr/bin/demo-helper Px, and a new profile
capability sys_niceDdeny capability sys_nice,
/tmp/demo.22t5Sb owner rwAinclude <abstractions/user-tmp>
/var/log/demo.log owner wO, A/var/log/demo.log w,
/var/lib/demo/state.db owner wAowner /var/lib/demo/state.db w,
/usr/share/demo/words-1.txt owner rG, Aowner /usr/share/demo/* r,
/etc/passwd, /etc/nsswitch.conf, /etc/demo/demo.conf owner rAone owner ... r, rule each
network connect inet stream3, Anetwork (connect) inet stream peer=(ip=127.0.0.1 port=9),
network create inet streamAinclude <abstractions/apache2-common> (the selected offer)
helper: /var/lib/demo/helper.out, /etc/demo/helper.conf, /etc/ld.so.cacheAone owner rule each in the helper's profile
Changed Local ProfilesSboth files written and reloaded

Known discrepancies seen in the session

  • The bracketed default of every rule question is Deny, also for complain-mode records.
  • abstractions/apache2-common is the first offer for any inet stream socket.
  • /etc/ld.so.cache is proposed although abstractions/base covers it, and abstractions/nameservice is not offered for /etc/nsswitch.conf: the tools do not expand variables in abstraction rules.
  • The refusal for a marked program prints lines of a Python stack before its message.

Roads from here

FILE ACCESS

PROFILE HEAD

QUALIFIERS

IN PRACTICE · general-purpose apps

IN PRACTICE · security-sensitive programs

RUNNING THE PARSER

TOOLS · utils/