LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-13-2017, 11:49 AM   #1
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Rep: Reputation: 19
Allowing a normal user application to modify network configuration


Hi all,

I'm writing an application that will be run by a normal user, and it needs to be able to set the configuration for the network adapter (I don't love the idea, but the client wants what the client wants). Basically, the user, within this application, needs to be able to set the IP address (static or DHCP), subnet, etc.

The application is a Qt app written in Python. Naturally, I don't want them to run the app as root, so I need a normal user to be able to bring ethernet interfaces up and down, change settings, etc. Since this is an Arch Linux installation, this is normally done with netctl and the profile configuration files in /etc/netctl. However, netctl is a wrapper around systemctl, and you still need to be root to use it.

So, I figured the easiest thing to do would be to grant the user sudo permissions with NOPASSWD for /usr/bin/netctl. In my sudoers file, I just added
Code:
normaluser ALL=NOPASSWD: /usr/bin/netctl
My normal user can then run "sudo netctl start|stop|status profile_name", and that user can bring the interface up and down without entering the password (which would be awkward in a GUI). If the user tries to do something nasty and run "sudo systemctl whatever", sudo won't allow it. So far, so good.

Now I'll just use the Python subprocess module to run netctl from my application. That seems secure enough, while still allowing the behavior the client needs. My question for you is... where do you see this blowing up in my face? Do you have any suggestions for improved security? Have I missed something in my sudo configuration that is a vulnerability? Better ideas altogether for how to handle this task? I'd appreciate any thoughts.

Thanks!
 
Old 03-14-2017, 04:15 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
I'm not familiar with netctl though I did look through its web pages. If the user could modify a configuration file to launch a script of their choosing, then all bets are off. I couldn't see a way for that to be done with netctl, but again I am not familiar with it. Anyway, that's where I'd look.

If possible, I'd tighten it down to something like this:

Code:
normaluser ALL=NOPASSWD: /usr/bin/netctl start profile_name, /usr/bin/netctl stop profile_name, /usr/bin/netctl status profile_name
Though it the profile_name varies to much, that might not be so practical.
 
1 members found this post helpful.
Old 03-14-2017, 04:37 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I would try to write a script which can run only the allowed commands (possibly processing command line arguments), and make that readonly. And users will be allowed to run only this script by sudoers.
 
1 members found this post helpful.
Old 03-15-2017, 02:43 PM   #4
MALDATA
Member
 
Registered: Mar 2005
Posts: 157

Original Poster
Rep: Reputation: 19
Thanks for your input!

I can keep the normal user on a short leash with sudo, and it sounds like that's the primary concern. If anyone else sees a problem with this method, please let me know. Thanks!
 
Old 03-16-2017, 01:34 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
sudo itself is not "enough", you need to know what is really allowed (just an example: allowing to execute vi as root usually means full access, because you can execute any command from vi).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Allowing normal user to run chmod ZAMO Linux - Security 9 02-23-2016 01:06 AM
disabling direct login for normal application user manoj.linux Linux - Enterprise 6 07-31-2013 06:35 AM
[SOLVED] Installed application with root privileges, need to run as normal user sabresong Linux - Newbie 3 07-28-2012 06:26 PM
[SOLVED] FIREFOX about:config - allowing normal user to make changes. daz__ Slackware 5 05-18-2012 09:51 AM
Allowing a normal nonroot user to create accounts? jon_k Linux - Software 3 07-10-2004 02:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration