The trouble with symbolic links
The trouble with symbolic links
Posted Jul 7, 2022 15:48 UTC (Thu) by iabervon (subscriber, #722)Parent article: The trouble with symbolic links
I think it would make sense to have the kernel not follow symlinks when doing path-based operations in general, and have user space libraries, when doing things that should possibly be affected by symlinks, call realpath(), validate the result as appropriate for having just been given the path from a possibly-malicious source, and use the result, which will probably be a path that works without the kernel following symlinks (or will fail safely).
I could imagine a C library change that would set the prctl and handle symlinks in user space with realpath() for the traditionally-named path-based functions, and include variants that you use instead if you're going to validate the path at all.
