Ship an opt-in AppArmor profile in the official Debian package

Aperta
#4,705 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
debian, go, linux
Ambito
devops, security

Direzione di ricerca

Start by locating the Debian package files and the existing systemd unit, then check how package installation and upgrades handle files under /etc. Validate whether the proposed AppArmor profile and systemd drop-in preserve default behavior with and without AppArmor. Done means the opt-in profile is shipped in the official .deb and the suggested install, upgrade, and runtime checks pass for its stated userspace proxy scope.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Proposal

Would the project ship a named AppArmor profile under /etc/apparmor.d/ in the official .deb, alongside the existing systemd unit? This would let profile updates travel with package updates. A named profile without an executable attachment can be loaded without changing how existing services and CLI invocations run. Document the drop-in below as the explicit opt-in, and preserve the service's default behavior on upgrades and on hosts without AppArmor.

The packaged service starts /usr/bin/sing-box with configuration under /etc/sing-box and state under /var/lib/sing-box. These paths provide a useful starting point for a policy that reads configuration and permits writes to application state.

Example for a basic userspace proxy

Example contents for a package-managed /etc/apparmor.d/local-sing-box on a host with AppArmor 4.0 policy support.

abi <abi/4.0>,
include <tunables/global>

profile local-sing-box {
  include <abstractions/base>
  include <abstractions/nameservice>
  include <abstractions/openssl>

  /usr/bin/sing-box mr,
  /etc/sing-box/ r,
  /etc/sing-box/config.json r,
  owner /var/lib/sing-box/ rw,
  owner /var/lib/sing-box/** rwk,

  @{PROC}/sys/net/core/somaxconn r,
  owner @{PROC}/[0-9]*/{cgroup,mountinfo} r,
  /sys/fs/cgroup/system.slice/sing-box.service/cpu.max r,

  network inet stream,
  network inet dgram,
  network inet6 stream,
  network inet6 dgram,
  network netlink raw,
}

Bind the loaded profile via /etc/systemd/system/sing-box.service.d/20-apparmor.conf.

[Unit]
Wants=apparmor.service
After=apparmor.service

[Service]
AppArmorProfile=local-sing-box

This is adapted from our policy for a userspace deployment. It assumes one configuration file and service-owned state. TUN, transparent proxying, process-based routing, external certificates, extra configuration files and packaged ExecReload need separate validation before claiming support.

Test package installation and upgrades with and without the drop-in. Suggested runtime checks include parsing and loading the profile before restarting, checking the live process label, exercising TCP/UDP traffic and DNS, verifying any configured cache survives a restart, and checking the kernel audit log. If reload is supported by the example, test the packaged SIGHUP path as well.

Lingua principale
Go
Stelle
40.4k
Fork
5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SagerNet/sing-box

Tutte le issue di SagerNet/sing-box

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.