36

I have been using snap for some time but after a recent upgrade, I get this error when I try opening any application

Snap-confine has elevated permissions and is not confined but should be.
Refusing to continue to avoid permission escalation attacks

I have tried various fixes but it keeps getting worse. Any idea on what I should do?

I also tried sudo apt purge snapd snap-confine && sudo apt install -y snapd but when I try opening pycharm-community, it doesn't do anything.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
ROOT-X17
  • 463
  • 1
  • 4
  • 8
  • Don't try using this command: `sudo apt purge snapd snap-confine` That will uninstall a lot of applications and that's not what you normally want. – Esteban Camargo Feb 21 '22 at 14:34

13 Answers13

64
sudo apparmor_parser -r /etc/apparmor.d/*snap-confine*
sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine*

Fixes it. No restart required.

Diego V
  • 6,189
  • 7
  • 40
  • 45
  • After power failure i can't start slack, vscode. This advice was helpfull for me. Ubuntu 21.10 – Sergio Belevskij Feb 16 '22 at 09:15
  • 1
    **It doesn't work for me**, now it says *"cannot change profile for the next exec call: No such file or directory"*. I did previously due to another error `apparmor_parser -r /etc/apparmor.d/*snap-confine*` `apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine*` now with this asnwer it's still broken. keep on search – Rodrigo May 28 '22 at 15:36
  • This is working for me but temporarily. After reboot, the same problem pursues, and I have to run these commands again. Is there a permanent solution ? – null Aug 18 '22 at 07:24
  • 1
    sudo apparmor_parser -r /etc/apparmor.d/*snap-confine* was enough for me! – Kjeld Flarup Aug 29 '22 at 05:46
23

This worked for me

service snapd.apparmor start 

(It needs the root.)

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
pasha5
  • 331
  • 1
  • 2
19

From https://apparmor.net/

AppArmor (app-armor) is an effective and easy-to-use Linux application security system. AppArmor proactively protects the operating system and applications from external or internal threats, even zero-day attacks, by enforcing good behavior and preventing both known and unknown application flaws from being exploited.

    # start the appormor system
    sudo systemctl start apparmor 
    # parse and reload all apparmor profiles of installed snap applications 
    sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/*
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
11
systemctl enable --now apparmor.service    
systemctl enable --now snapd.apparmor.service

from here

Pavlikooo
  • 176
  • 1
  • 5
4

This is what worked for me on Kali Linux:

sudo apparmor_parser -r /etc/apparmor.d/*snap-confine*
sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine*
systemctl enable --now snapd.apparmor.service
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
2

This command helped me fix docker-compose:

sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/*

You can check if docker-compose works by using command:

docker-compose version
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
ayushaks
  • 21
  • 2
1

In my case it was caused by a bad AppArmor profile being present and loaded in complain (or enforce?) mode in

/etc/apparmor.d/usr.bin.snap

This apparently lead to snap not being able to determine the number of the snap and therefor caused a bad profile to be added to AppArmor.

"aa-status" outputed lines such as:

/usr/bin/snap//null-/usr/lib/snapd/snap-confine

for being in enforce mode

I moved that file (/etc/apparmor.d/usr.bin.snap) to my home directory, ran "sudo aa-remove-unknown" and "sudo systemctl restart apparmor" after which everything was back to normal.

However I don't know the origins of /etc/apparmor.d/usr.bin.snap so keep in mind that there might be something wrong with the system.

1

I had the same problem when using snap to run scrcpy. I tried this suggestion first and it worked:

sudo snap refresh

(This suggestion found at https://github.com/canonical/microk8s/issues/249)

django
  • 11
  • 1
0

This command also worked in my case :-

$ sudo service snapd.apparmor start
$ whatsdesk

Thank you.

Akash Kumar
  • 29
  • 1
  • 1
  • 8
0

What is really works is pavlikoo's answer

But in some cases, it also would be better to execute first:

sudo systemctl enable snapd

And don't forget to add sudo to pavlikoo's commands if you don't have special permissions.

0

Indeed AppArmor was not running. Some other bug in AppArmor will disable the whole snap! This has to be fixed before AppArmor can start.

Nov 21 00:24:40 kfc-XPS-15-9560 apparmor.systemd[201673]: AppArmor parser error for /etc/apparmor.d/usr.bin.tcpdump in profile /etc/apparmor.d/usr.bin.tcpdump at line 64: Could not open 'local/usr.sbin.tcpdump'
Kjeld Flarup
  • 1,471
  • 10
  • 15
0

For me after executing

sudo apparmor_parser -r /etc/apparmor.d/*snap-confine*
sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine*

i got an error of:

missing profile snap.docker.compose.
Please make sure that the snapd.apparmor service is enabled and started

It was fixed with

sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.docker.compose

following this askubuntu thread: https://askubuntu.com/questions/1248349/docker-compose-denied-by-apparmor-outside-of-home-how-to-fix

Kelfindel
  • 23
  • 5
0
sudo systemctl enable snapd.service   
sudo systemctl start snapd.service
service snapd.apparmor start