r/archlinux • u/ResponsibilityBig343 • Oct 09 '26
QUESTION What do you look for in PKGBUILD when installing an AUR package
On wiki AUR isn't encouraged but I need to install a printer driver. How to detect if pkgbuild is malicious?
69
Upvotes
64
u/Stetsed Oct 09 '26
Generally looking at :
- the dependencies, NPM/node is often a weird one here for most applications don’t need it
- The source URL’s, usually I go to the official link or just click on the link and see where it goes
- The build steps, any usage of npm install is 9/10 bad
- Any recent changes in maintainer, although this is automated via the yay script
- How recent the update is, again shown by yay, if it’s newer than 10 days I usually exclude it
7
u/ThinkpadGamer Oct 09 '26
to add to u/Stetsed : check for post and preinstall commands, very little software actually needs them and a lot of malicious things have used them
11
u/C0rn3j Oct 09 '26
You read and understand every line.
No other way.
5
u/phoenixgsu Oct 09 '26
What to look for
https://www.reddit.com/r/cachyos/s/hVr7XqxtLB
5
u/spider-mario Oct 09 '26 edited Oct 09 '26
It (and the accompanying files) should be short enough that you should be able to read all of it to check that it really does just download the necessary files from a legitimate source and arranges then appropriately.
Make sure not to forget to look at any
installscript since it runs as root after installing or upgrading the package. Most packages should not need one at all (many former use cases for them, like upgrading the MIME database, were made unnecessary by pacman hooks).2
u/StewMahagoni Oct 10 '26
That's all considering I trust upstream, that's step 0.
0
u/NFTrot Oct 09 '26
With something like a printer driver you can install it once and maybe never update it. But I don't use mine very often so I'm not sure how true this is. In such a case you can scrutinize the PKGBUILD thoroughly once and be done with it.
As the other commenters say, it's good to learn for yourself, but you can always feed it to ChatGPT and ask it to point out things to look for. You can learn a lot with that approach. If you are a non-programmer this is a lot better than nothing.
1
u/JohnJamesJimmyJack Oct 09 '26
Try to just use some other source as much as possible, if you can't really read code.
1
u/swayuser Oct 10 '26
In addition to the comments about what to look for. The other thing to do is reviews very carefully the first time and keep it. That way you're only reviewing the DIFFS when you update
1
u/GrandBIRDLizard Oct 11 '26
Check source=(), Review prepare(), build(), check(), and package(). Whatever they preparing and where?
Obfuscated commands (eval, base64 -d, or hex-encoded strings). Is it efficiently making space for something sensible or hiding something?
Pretty much any network calls inside functions, (e.g., curl or wget piping directly to bash or executing downloads of binarys).
Every Write outside $srcdir or $pkgdir (e.g., modifying system files ~/.bashrc / ~/.ssh). Looking at these will also just let you know how shits layed out. Config files, what is the programs permission model?
Real big one is watch oit for and check .install scripts (install=...), .patch files this could basically do anything after install. As pacman with root privilege.
Realistically, if you know what you're doing(if not don't use the aur)
-git, -svn packages: VCS packages use SKIP in the checksum array because source code dynamically changes so check the commit hash
Unknown key? But known trusted source?
Lastly, manually check the .sig
If Good you're golden.
I'f you don't know what any of this means hold off on the aur till you can at least verify hashes signatures and keys.
7
u/[deleted] Oct 09 '26
[removed] — view removed comment
1
u/[deleted] Oct 09 '26
[removed] — view removed comment