3

For security purposes the application needs to know, securely who is logged in and what groups they are authorised for. This must be done securely so that a user application cannot perform a man in the middle attack. For example reading the USER environment variable is an insecure way of establishing the user's identity.

I suspect the answer may be by using some DBUS protocol.

  • The exact scenario is unknown. It looks for me like you want to get these information when running with the privileges of the user inside the application, but while not trusting the application your are running in. Even if you find functions to get this information in a secure way the untrusted application might modify the values returned by these functions or might change the control-flow so that believes that it got the correct values. You would need more privileges than the application so that the application cannot manipulate this and of course you need to be able to trust the system. – Steffen Ullrich Aug 15 '17 at 4:45
  • I trust the application. But I do envisage working in an untrusted user environment with potentially smart users trying to subvert the system by running another application or modifying the user environment that they have access to in some way. I would not like them to be able to simply change the value of an environment variable to circumvent security. Would like them to have to work a bit harder than that> – tony wallace Aug 16 '17 at 8:04
  • If you trust the application simply use the appropriate system/library calls, i.e. getuid, getgid and getgroups. Of course, smart users might preload libraries to change the behavior of these calls or attach an debugger to change the execution flow of the application no matter what these functions return. Again, running with the same or lower privileges as the untrusted user makes it impossible to protect the application. – Steffen Ullrich Aug 16 '17 at 8:14
  • This sound like exactly what PAM is designed for. Note that the application doing the verification must be running as a privileged user or otherwise a user unrelated to the unauthenticated user, or things like ptrace() and LD_PRELOAD may be used to hijack the application and trigger an automatic authentication pass. – forest Jan 2 '18 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.