SlideShare a Scribd company logo
1 of 44
Download to read offline
Peter Czanik
Open Source Evangelist
One Identity
@PCzanik
Security Starts Here | One Identity - Restricted - Confidential
Sudo: Giving
access while
staying in control
• Working at the Budapest office of One Identity
(formerly known as Balabit)
• syslog-ng & sudo upstream
• Helping in RPM and FreeBSD packaging
• Blogger and speaker
About me
Security Starts Here | One Identity - Restricted - Confidential
• What is sudo?
• Some lesser-known features
• What’s new?
• JSON-formatted logging
• Relays
• Chroot, working directory
• Logging sub-commands
• Masking passwords
• Getting more precise information
Overview
Security Starts Here | One Identity - Restricted - Confidential
- Is sudo a prefix for administrative commands?
- Yes, but also a lot more:
• Control and log access
• Record and play back terminal input and output
• Modular: extend with your own code, now even in
Python
• It even has humor!
What is sudo?
• Default config
%wheel ALL=(ALL) ALL
• (Almost) all permissions to the wheel group
• Still useful:
• Controls access
• No shared password
• You see who did what
A basic /etc/sudoers
• Recording the terminal
• Playback
• Difficult to modify (not cleartext)
• Saved locally, therefore easy to delete with
unlimited access
• Sudo 1.9: central session recording using sudo_logsrvd
Session recording
• Propagates in real-time
• Can’t be modified locally
• Many limitations (aliases, etc.)
LDAP for central management
• Extending sudo using Python
• Using the same APIs as C plugins
• API: https://www.sudo.ws/man/sudo_plugin.man.html
• Python plugin documentation:
https://www.sudo.ws/man/sudo_plugin_python.man.html
• No development environment or compilation needed
Python support
• Accessing input and output from user sessions
• Python example:
IO logs API
• Fun, but not always politically correct :)
Defaults insults
czanik@linux-mewy:~> sudo ls
[sudo] password for root:
Hold it up to the light --- not a brain in sight!
[sudo] password for root:
My pet ferret can type better than you!
[sudo] password for root:
sudo: 3 incorrect password attempts
czanik@linux-mewy:~>
Insults
• Until now I talked about sudo <= 1.9.0 (most
“enterprise” & “LTS” distros)
• Since late 2020 most distros changed to 1.9.0 or
later
• Current version is 1.9.14
• Some 1.9.15 features mentioned at the end:
coming soon ☺
• Sudo installers:
https://www.sudo.ws/getting/packages/
Sudo versions
• Introduced in sudo 1.9.4
• Traditionally plain-text logs with minimal information
• Feature introduced due to old syslog constraints
• Nov 18 12:31:33 centos7sudo sudo[30666]: czanik : 3
incorrect password attempts ; TTY=pts/0 ; PWD=/home/czanik ;
USER=root ; COMMAND=/bin/bash
• Nov 18 12:31:43 centos7sudo sudo[30670]: czanik :
TTY=pts/0 ; PWD=/home/czanik ; USER=root ;
COMMAND=/bin/bash
• Nov 18 12:31:49 centos7sudo sudo[30670]: czanik : command
rejected by I/O plugin ; TTY=pts/0 ; PWD=/home/czanik ;
USER=root ; COMMAND=/bin/bash
JSON-formatted logs
Security Starts Here | One Identity - Restricted - Confidential
• JSON-formatted logs have more information in a structured format
Defaults log_format=json
Nov 18 12:40:30 centos7sudo sudo[30891]:
@cee:{"reject":{"reason":"command rejected by I/O
plugin","server_time":{"seconds":1605699630,"nanoseconds":9332939
11,"iso8601":"20201118114030Z","localtime":"Nov 18
11:40:30"},"submit_time":{"seconds":1605699620,"nanoseconds":130
500349,"iso8601":"20201118114020Z","localtime":"Nov 18
11:40:20"},"submituser":"czanik","command":"/bin/bash","runuser":"ro
ot","runcwd":"/home/czanik","ttyname":"/dev/pts/0","submithost":"cent
os7sudo.localdomain","submitcwd":"/home/czanik","runuid":0,"columns"
:118,"lines":60,"runargv":["/bin/bash"]}}
JSON-formatted logs
Security Starts Here | One Identity - Restricted - Confidential
• Use jq or similar to make logs more human readable on the terminal:
{
"sudo": {
"accept": {
"uuid": "616bc9efcf-b239-469d-60ee-deb5af8ce6",
"server_time": {
"seconds": 1643374700,
"nanoseconds": 222446715,
"iso8601": "20220128125820Z",
"localtime": "Jan 28 13:58:20"
},
"submituser": "czanik",
[…]
JSON-formatted logs
Security Starts Here | One Identity - Restricted - Confidential
• Logging:
• Syslog
• Audit plugin API – reachable also from Python for custom
logging
• Sudo 1.9.4 added logging to sudo_logsrvd
Defaults log_servers=172.16.167.150
Logging to sudo_logsrvd
Security Starts Here | One Identity - Restricted - Confidential
• Sudo_logsrvd sends logs to syslog
• “HOST” field shows where logs are coming from
Nov 18 12:40:16 centos8splunk.localdomain sudo[21028]: czanik : 3 incorrect
password attempts ; HOST=centos7sudo.localdomain ; TTY=pts/0 ;
PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash
Nov 18 12:40:23 centos8splunk.localdomain sudo[21028]: czanik :
HOST=centos7sudo.localdomain ; TTY=pts/0 ; PWD=/home/czanik ; USER=root
; TSID=00000A ; COMMAND=/bin/bash
Nov 18 12:40:30 centos8splunk.localdomain sudo[21028]: czanik : command
rejected by I/O plugin ; HOST=centos7sudo.localdomain ; TTY=pts/0 ;
PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash
• JSON formatting available
Logging to sudo_logsrvd
Security Starts Here | One Identity - Restricted - Confidential
• Sudo_logsrvd collects session recordings to a central
location
• Originally all sudo clients sent recordings directly
• Sudo version 1.9.7 introduced relay mode
• You can have multiple levels of relays to structure your
network
Using sudo_logsrvd in relay mode
Security Starts Here | One Identity - Restricted - Confidential
• Collect recordings even when central server is
unavailable (maintenance or network problem)
• Have a single network connection through the firewall
instead of granting each host access
• Run it on a gateway host to relay from networks
without direct Internet access, like AWS private
networks
Why relay mode?
Security Starts Here | One Identity - Restricted - Confidential
• Configuring the client or the central server is the same
• On the relay:
• Where to forward
• In case of unreliable networks, store first (default: false)
relay_host = 172.16.167.161
store_first = true
• TLS encryption available
Configuring relay mode
Security Starts Here | One Identity - Restricted - Confidential
• Previously, full root shell access was needed to start an
application from a user-inaccessible directory
• Full root access easily gained using chroot
• Starting with sudo 1.9.3, both can be configured from
/etc/sudoers
Using chroot and cwd
Security Starts Here | One Identity - Restricted - Confidential
• The chroot command needs root privileges
• Using with sudo, it is still possible to sudo chroot /
• Chroot support must be explicitly enabled in sudoers
Using chroot
Security Starts Here | One Identity - Restricted - Confidential
• If directory is not restricted in sudoers:
Defaults:%wheel runchroot=*
• sudo --chroot / -s can do the same ☺
• But at least it is nicely logged:
Sep 24 15:58:55 centos7sudo sudo[8149]: czanik :
TTY=pts/0 ; CHROOT=/ ; PWD=/home/czanik ;
USER=root ; TSID=00001G ; COMMAND=/bin/bash
Using chroot
Security Starts Here | One Identity - Restricted - Confidential
• Directory can be restricted in sudoers:
Defaults:%wheel runchroot=/var/lib/mock/epel7-
x86_64/root
• If chroot or a given directory is not allowed, it is logged:
Sep 25 08:43:32 centos7sudo sudo[2640]: czanik : user
not allowed to change root directory to
/an/interesting/directory ; TTY=pts/0 ;
CHROOT=/an/interesting/directory ; PWD=/home/czanik ;
USER=root ; COMMAND=/bin/bash
Using chroot
Security Starts Here | One Identity - Restricted - Confidential
• Before sudo 1.9.8, only session recording helped in
case of shell or editor access
• Watching recordings is boring and time consuming
• 1.9.8 introduced:
• Logging
• Intercepting
• Works in most cases (does not work for built-in
commands, etc.)
Logging and intercepting sub-commands
Security Starts Here | One Identity - Restricted - Confidential
• Enable with:
Defaults log_subcmds
• Turn on JSON formatting:
Defaults log_format=json
Logging sub-commands
Security Starts Here | One Identity - Restricted - Confidential
I Unnamed (Modified) Row 14 Col 1
czplaptop:/home/czanik # id
uid=0(root) gid=0(root) groups=0(root)
czplaptop:/home/czanik # ls /usr/share/syslog-ng/include/scl/
apache ewmm logmatic snmptrap
cee fortigate mbox solaris
checkpoint graphite netskope sudo
cim graylog2 nodejs sumologic
cisco iptables osquery syslogconf
collectd junos pacct system
default-network-drivers linux-audit paloalto telegram
discord loadbalancer rewrite websense
elasticsearch loggly slack windowseventlog
czplaptop:/home/czanik # exit
Logging sub-commands: editor screenshot
Security Starts Here | One Identity - Restricted - Confidential
• Log without logging subcommands:
Aug 30 13:03:00 czplaptop sudo[10150]: Czanik :
TTY=pts/1 ; PWD=/home/Czanik ; USER=root ;
COMMAND=/usr/bin/joe
Logging sub-commands
Security Starts Here | One Identity - Restricted - Confidential
•Logs when logging subcommands:
Aug 30 13:13:14 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/joe
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/sh -c /bin/bash
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/readlink
/proc/10889/exe
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/dircolors -b
/etc/DIR_COLORS
[…]
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/sed -r
s@/*:|([^]):@1n@g;H;x;s@/n@n@
Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/tty
Aug 30 13:13:42 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/id
Aug 30 13:13:56 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/ls -A -N --color=none -T
0 /usr/share/syslog-ng/include/scl/
Logging sub-commands
Security Starts Here | One Identity - Restricted - Confidential
• Log with JSON formatting:
Aug 30 13:29:28 czplaptop sudo[11740]:
@cee:{"sudo":{"accept":{"uuid":"18f25b2438-0c44-ddaf-a264-
c70998d319","server_time":{"seconds":1630322968,"nanoseconds":12453428
3,"iso8601":"20210830112928Z","localtime":"Aug 30
11:29:28"},"submit_time":{"seconds":1630322965,"nanoseconds":357407987,
"iso8601":"20210830112925Z","localtime":"Aug 30
11:29:25"},"submituser":"czanik","command":"/usr/bin/joe","runuser":"root","r
uncwd":"/home/czanik","ttyname":"/dev/pts/1","submithost":"czplaptop","subm
itcwd":"/home/czanik","runuid":0,"columns":80,"lines":24,"runargv":["joe","/et
c/issue"],"runenv":["LANG=en_US.UTF-
8","COLORTERM=truecolor","TERM=xterm-
256color","MAIL=/var/mail/root","PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local
/bin:/usr/local/sbin","LOGNAME=root","USER=root","HOME=/root","SHELL=/bin
/bash","SUDO_COMMAND=/usr/bin/joe
/etc/issue","SUDO_USER=czanik","SUDO_UID=1000","SUDO_GID=100"]}}}
Logging sub-commands
Security Starts Here | One Identity - Restricted - Confidential
• Can prevent applications from running
• Enabling is a two-step process in sudoers
Defaults intercept
• And the actual rule:
czanik ALL = (ALL) ALL, !/usr/bin/who
Intercepting sub-commands
Security Starts Here | One Identity - Restricted - Confidential
• Even if running a shell with full root access:
czanik@czplaptop:~> sudo -s
czplaptop:/home/czanik # who
Sorry, user czanik is not allowed to execute
'/usr/bin/who' as root on czplaptop.
bash: /usr/bin/who: Permission denied
Intercepting sub-commands
Security Starts Here | One Identity - Restricted - Confidential
• Visibility is not always good
• Session recordings can include passwords
Hiding passwords in recordings
Security Starts Here | One Identity - Restricted - Confidential
• Recordings are saved under /var/log/sudo-io/
• No sudo tool to display input
• Files are compressed
zless /var/log/sudo-io/00/00/01/ttyin
passwd bla^Mblabla^Mblabla^M^D
Hiding passwords in recordings
Security Starts Here | One Identity - Restricted - Confidential
• In /etc/sudoers:
Defaults !log_passwords
• Passwords are masked in session recordings:
passwd bla^M********^M********^M^D
Hiding passwords in recordings
Security Starts Here | One Identity - Restricted - Confidential
• The list pseudo-command allows regular users to list
other user’s privileges
• Audit without full admin access
• Introduced in sudo version 1.9.13
bla ALL=(ALL) list
Listing privileges
bla@czplaptop:~> sudo -l
bla's password:
Matching Defaults entries for bla on czplaptop:
always_set_home,
secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin,
env_reset, env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION
LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE",
!insults, ignore_iolog_errors, log_output, log_input
User bla may run the following commands on czplaptop:
(ALL) list
bla@czplaptop:~> sudo -U czanik -l
Matching Defaults entries for czanik on czplaptop:
always_set_home,
secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin,
env_reset, env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION
LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE",
!insults, ignore_iolog_errors, log_output, log_input
User czanik may run the following commands on czplaptop:
(ALL) ALL
List privileges
• The long list (-ll) option now also prints the file name
• Arrives in sudo version 1.9.15
List privileges
leap154b:~ # sudo -U mytest -ll
Matching Defaults entries for mytest on leap154b:
always_set_home, secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin, env_reset,
env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME
LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE", insults, targetpw
User mytest may run the following commands on leap154b:
Sudoers entry: /etc/sudoers
RunAsUsers: ALL
Commands:
ALL
Sudoers entry: /etc/sudoers.d/foo
RunAsUsers: root
Commands:
ALL
List privileges
• The file name and line number for the rule in the
SOURCE filed of JSON-formatted logs
• Arrives in sudo version 1.9.15
"source":"/etc/sudoers:66:23"
"source":"/etc/sudoers.d/foo:1:15"
SOURCE in JSON logs
• Recent versions of sudo let you see and control a lot
more activities:
• More detailed, easier to use log messages
• Log sessions through relays
• Less need for root shells: chroot & cwd support
• Track and intercept sub-commands
• Password masking in logs
• Listing privileges
Summary
Security Starts Here | One Identity - Restricted - Confidential
• Sudo website: https://www.sudo.ws/
• My email: peter.czanik@oneidentity.com
• Twitter: @Pczanik
Questions?
Sudo – Giving access while staying in control
Sudo – Giving access while staying in control

More Related Content

Similar to Sudo – Giving access while staying in control

Basic security &amp; info
Basic security &amp; infoBasic security &amp; info
Basic security &amp; infoTola LENG
 
Presentation nix
Presentation nixPresentation nix
Presentation nixfangjiafu
 
Presentation nix
Presentation nixPresentation nix
Presentation nixfangjiafu
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoTiago Cruz
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactAlessandro Selli
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production OverviewDelve Labs
 
What’s new in Sudo 1.8?
What’s new in Sudo 1.8?What’s new in Sudo 1.8?
What’s new in Sudo 1.8?Tyler Reese
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX SecurityHelpSystems
 
8 steps to protect your cisco router
8 steps to protect your cisco router8 steps to protect your cisco router
8 steps to protect your cisco routerIT Tech
 
Hadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsHadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsSruthi Kumar Annamnidu
 
Asiabsdcon2013
Asiabsdcon2013Asiabsdcon2013
Asiabsdcon2013krispcbsd
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guideCraig Cannon
 
How to secure ubuntu 12.04
How to secure ubuntu 12.04 How to secure ubuntu 12.04
How to secure ubuntu 12.04 John Richard
 
Server hardening
Server hardeningServer hardening
Server hardeningTeja Babu
 
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiInSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiYossi Sassi
 

Similar to Sudo – Giving access while staying in control (20)

Cent os 5 ssh
Cent os 5 sshCent os 5 ssh
Cent os 5 ssh
 
Basic security &amp; info
Basic security &amp; infoBasic security &amp; info
Basic security &amp; info
 
Presentation nix
Presentation nixPresentation nix
Presentation nix
 
Presentation nix
Presentation nixPresentation nix
Presentation nix
 
Linux Hardening - Made Easy
Linux Hardening - Made EasyLinux Hardening - Made Easy
Linux Hardening - Made Easy
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso Remoto
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
Penetration Testing Boot CAMP
Penetration Testing Boot CAMPPenetration Testing Boot CAMP
Penetration Testing Boot CAMP
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production Overview
 
What’s new in Sudo 1.8?
What’s new in Sudo 1.8?What’s new in Sudo 1.8?
What’s new in Sudo 1.8?
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security
 
8 steps to protect your cisco router
8 steps to protect your cisco router8 steps to protect your cisco router
8 steps to protect your cisco router
 
Hadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsHadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup Insights
 
Asiabsdcon2013
Asiabsdcon2013Asiabsdcon2013
Asiabsdcon2013
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guide
 
How to secure ubuntu 12.04
How to secure ubuntu 12.04 How to secure ubuntu 12.04
How to secure ubuntu 12.04
 
Security Onion
Security OnionSecurity Onion
Security Onion
 
Server hardening
Server hardeningServer hardening
Server hardening
 
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi SassiInSecure Remote Operations - NullCon 2023 by Yossi Sassi
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
 

More from All Things Open

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityAll Things Open
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best PracticesAll Things Open
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public PolicyAll Things Open
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...All Things Open
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashAll Things Open
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptAll Things Open
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?All Things Open
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractAll Things Open
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlowAll Things Open
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and SuccessAll Things Open
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with BackgroundAll Things Open
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblyAll Things Open
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksAll Things Open
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptAll Things Open
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramAll Things Open
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceAll Things Open
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamAll Things Open
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsAll Things Open
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...All Things Open
 
Building AlmaLinux OS without RHEL sources code
Building AlmaLinux OS without RHEL sources codeBuilding AlmaLinux OS without RHEL sources code
Building AlmaLinux OS without RHEL sources codeAll Things Open
 

More from All Things Open (20)

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of Observability
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best Practices
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil Nash
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScript
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and Success
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in Haystacks
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit Intercept
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship Program
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache Beam
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
 
Building AlmaLinux OS without RHEL sources code
Building AlmaLinux OS without RHEL sources codeBuilding AlmaLinux OS without RHEL sources code
Building AlmaLinux OS without RHEL sources code
 

Recently uploaded

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Sudo – Giving access while staying in control

  • 1.
  • 2. Peter Czanik Open Source Evangelist One Identity @PCzanik Security Starts Here | One Identity - Restricted - Confidential Sudo: Giving access while staying in control
  • 3. • Working at the Budapest office of One Identity (formerly known as Balabit) • syslog-ng & sudo upstream • Helping in RPM and FreeBSD packaging • Blogger and speaker About me Security Starts Here | One Identity - Restricted - Confidential
  • 4. • What is sudo? • Some lesser-known features • What’s new? • JSON-formatted logging • Relays • Chroot, working directory • Logging sub-commands • Masking passwords • Getting more precise information Overview Security Starts Here | One Identity - Restricted - Confidential
  • 5. - Is sudo a prefix for administrative commands? - Yes, but also a lot more: • Control and log access • Record and play back terminal input and output • Modular: extend with your own code, now even in Python • It even has humor! What is sudo?
  • 6. • Default config %wheel ALL=(ALL) ALL • (Almost) all permissions to the wheel group • Still useful: • Controls access • No shared password • You see who did what A basic /etc/sudoers
  • 7. • Recording the terminal • Playback • Difficult to modify (not cleartext) • Saved locally, therefore easy to delete with unlimited access • Sudo 1.9: central session recording using sudo_logsrvd Session recording
  • 8. • Propagates in real-time • Can’t be modified locally • Many limitations (aliases, etc.) LDAP for central management
  • 9. • Extending sudo using Python • Using the same APIs as C plugins • API: https://www.sudo.ws/man/sudo_plugin.man.html • Python plugin documentation: https://www.sudo.ws/man/sudo_plugin_python.man.html • No development environment or compilation needed Python support
  • 10. • Accessing input and output from user sessions • Python example: IO logs API
  • 11. • Fun, but not always politically correct :) Defaults insults czanik@linux-mewy:~> sudo ls [sudo] password for root: Hold it up to the light --- not a brain in sight! [sudo] password for root: My pet ferret can type better than you! [sudo] password for root: sudo: 3 incorrect password attempts czanik@linux-mewy:~> Insults
  • 12. • Until now I talked about sudo <= 1.9.0 (most “enterprise” & “LTS” distros) • Since late 2020 most distros changed to 1.9.0 or later • Current version is 1.9.14 • Some 1.9.15 features mentioned at the end: coming soon ☺ • Sudo installers: https://www.sudo.ws/getting/packages/ Sudo versions
  • 13. • Introduced in sudo 1.9.4 • Traditionally plain-text logs with minimal information • Feature introduced due to old syslog constraints • Nov 18 12:31:33 centos7sudo sudo[30666]: czanik : 3 incorrect password attempts ; TTY=pts/0 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash • Nov 18 12:31:43 centos7sudo sudo[30670]: czanik : TTY=pts/0 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash • Nov 18 12:31:49 centos7sudo sudo[30670]: czanik : command rejected by I/O plugin ; TTY=pts/0 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash JSON-formatted logs Security Starts Here | One Identity - Restricted - Confidential
  • 14. • JSON-formatted logs have more information in a structured format Defaults log_format=json Nov 18 12:40:30 centos7sudo sudo[30891]: @cee:{"reject":{"reason":"command rejected by I/O plugin","server_time":{"seconds":1605699630,"nanoseconds":9332939 11,"iso8601":"20201118114030Z","localtime":"Nov 18 11:40:30"},"submit_time":{"seconds":1605699620,"nanoseconds":130 500349,"iso8601":"20201118114020Z","localtime":"Nov 18 11:40:20"},"submituser":"czanik","command":"/bin/bash","runuser":"ro ot","runcwd":"/home/czanik","ttyname":"/dev/pts/0","submithost":"cent os7sudo.localdomain","submitcwd":"/home/czanik","runuid":0,"columns" :118,"lines":60,"runargv":["/bin/bash"]}} JSON-formatted logs Security Starts Here | One Identity - Restricted - Confidential
  • 15. • Use jq or similar to make logs more human readable on the terminal: { "sudo": { "accept": { "uuid": "616bc9efcf-b239-469d-60ee-deb5af8ce6", "server_time": { "seconds": 1643374700, "nanoseconds": 222446715, "iso8601": "20220128125820Z", "localtime": "Jan 28 13:58:20" }, "submituser": "czanik", […] JSON-formatted logs Security Starts Here | One Identity - Restricted - Confidential
  • 16. • Logging: • Syslog • Audit plugin API – reachable also from Python for custom logging • Sudo 1.9.4 added logging to sudo_logsrvd Defaults log_servers=172.16.167.150 Logging to sudo_logsrvd Security Starts Here | One Identity - Restricted - Confidential
  • 17. • Sudo_logsrvd sends logs to syslog • “HOST” field shows where logs are coming from Nov 18 12:40:16 centos8splunk.localdomain sudo[21028]: czanik : 3 incorrect password attempts ; HOST=centos7sudo.localdomain ; TTY=pts/0 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash Nov 18 12:40:23 centos8splunk.localdomain sudo[21028]: czanik : HOST=centos7sudo.localdomain ; TTY=pts/0 ; PWD=/home/czanik ; USER=root ; TSID=00000A ; COMMAND=/bin/bash Nov 18 12:40:30 centos8splunk.localdomain sudo[21028]: czanik : command rejected by I/O plugin ; HOST=centos7sudo.localdomain ; TTY=pts/0 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash • JSON formatting available Logging to sudo_logsrvd Security Starts Here | One Identity - Restricted - Confidential
  • 18. • Sudo_logsrvd collects session recordings to a central location • Originally all sudo clients sent recordings directly • Sudo version 1.9.7 introduced relay mode • You can have multiple levels of relays to structure your network Using sudo_logsrvd in relay mode Security Starts Here | One Identity - Restricted - Confidential
  • 19. • Collect recordings even when central server is unavailable (maintenance or network problem) • Have a single network connection through the firewall instead of granting each host access • Run it on a gateway host to relay from networks without direct Internet access, like AWS private networks Why relay mode? Security Starts Here | One Identity - Restricted - Confidential
  • 20. • Configuring the client or the central server is the same • On the relay: • Where to forward • In case of unreliable networks, store first (default: false) relay_host = 172.16.167.161 store_first = true • TLS encryption available Configuring relay mode Security Starts Here | One Identity - Restricted - Confidential
  • 21. • Previously, full root shell access was needed to start an application from a user-inaccessible directory • Full root access easily gained using chroot • Starting with sudo 1.9.3, both can be configured from /etc/sudoers Using chroot and cwd Security Starts Here | One Identity - Restricted - Confidential
  • 22. • The chroot command needs root privileges • Using with sudo, it is still possible to sudo chroot / • Chroot support must be explicitly enabled in sudoers Using chroot Security Starts Here | One Identity - Restricted - Confidential
  • 23. • If directory is not restricted in sudoers: Defaults:%wheel runchroot=* • sudo --chroot / -s can do the same ☺ • But at least it is nicely logged: Sep 24 15:58:55 centos7sudo sudo[8149]: czanik : TTY=pts/0 ; CHROOT=/ ; PWD=/home/czanik ; USER=root ; TSID=00001G ; COMMAND=/bin/bash Using chroot Security Starts Here | One Identity - Restricted - Confidential
  • 24. • Directory can be restricted in sudoers: Defaults:%wheel runchroot=/var/lib/mock/epel7- x86_64/root • If chroot or a given directory is not allowed, it is logged: Sep 25 08:43:32 centos7sudo sudo[2640]: czanik : user not allowed to change root directory to /an/interesting/directory ; TTY=pts/0 ; CHROOT=/an/interesting/directory ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash Using chroot Security Starts Here | One Identity - Restricted - Confidential
  • 25. • Before sudo 1.9.8, only session recording helped in case of shell or editor access • Watching recordings is boring and time consuming • 1.9.8 introduced: • Logging • Intercepting • Works in most cases (does not work for built-in commands, etc.) Logging and intercepting sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 26. • Enable with: Defaults log_subcmds • Turn on JSON formatting: Defaults log_format=json Logging sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 27. I Unnamed (Modified) Row 14 Col 1 czplaptop:/home/czanik # id uid=0(root) gid=0(root) groups=0(root) czplaptop:/home/czanik # ls /usr/share/syslog-ng/include/scl/ apache ewmm logmatic snmptrap cee fortigate mbox solaris checkpoint graphite netskope sudo cim graylog2 nodejs sumologic cisco iptables osquery syslogconf collectd junos pacct system default-network-drivers linux-audit paloalto telegram discord loadbalancer rewrite websense elasticsearch loggly slack windowseventlog czplaptop:/home/czanik # exit Logging sub-commands: editor screenshot Security Starts Here | One Identity - Restricted - Confidential
  • 28. • Log without logging subcommands: Aug 30 13:03:00 czplaptop sudo[10150]: Czanik : TTY=pts/1 ; PWD=/home/Czanik ; USER=root ; COMMAND=/usr/bin/joe Logging sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 29. •Logs when logging subcommands: Aug 30 13:13:14 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/joe Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/sh -c /bin/bash Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/bin/bash Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/readlink /proc/10889/exe Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/dircolors -b /etc/DIR_COLORS […] Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/sed -r s@/*:|([^]):@1n@g;H;x;s@/n@n@ Aug 30 13:13:37 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/tty Aug 30 13:13:42 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/id Aug 30 13:13:56 czplaptop sudo[10874]: czanik : TTY=pts/1 ; PWD=/home/czanik ; USER=root ; COMMAND=/usr/bin/ls -A -N --color=none -T 0 /usr/share/syslog-ng/include/scl/ Logging sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 30. • Log with JSON formatting: Aug 30 13:29:28 czplaptop sudo[11740]: @cee:{"sudo":{"accept":{"uuid":"18f25b2438-0c44-ddaf-a264- c70998d319","server_time":{"seconds":1630322968,"nanoseconds":12453428 3,"iso8601":"20210830112928Z","localtime":"Aug 30 11:29:28"},"submit_time":{"seconds":1630322965,"nanoseconds":357407987, "iso8601":"20210830112925Z","localtime":"Aug 30 11:29:25"},"submituser":"czanik","command":"/usr/bin/joe","runuser":"root","r uncwd":"/home/czanik","ttyname":"/dev/pts/1","submithost":"czplaptop","subm itcwd":"/home/czanik","runuid":0,"columns":80,"lines":24,"runargv":["joe","/et c/issue"],"runenv":["LANG=en_US.UTF- 8","COLORTERM=truecolor","TERM=xterm- 256color","MAIL=/var/mail/root","PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local /bin:/usr/local/sbin","LOGNAME=root","USER=root","HOME=/root","SHELL=/bin /bash","SUDO_COMMAND=/usr/bin/joe /etc/issue","SUDO_USER=czanik","SUDO_UID=1000","SUDO_GID=100"]}}} Logging sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 31. • Can prevent applications from running • Enabling is a two-step process in sudoers Defaults intercept • And the actual rule: czanik ALL = (ALL) ALL, !/usr/bin/who Intercepting sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 32. • Even if running a shell with full root access: czanik@czplaptop:~> sudo -s czplaptop:/home/czanik # who Sorry, user czanik is not allowed to execute '/usr/bin/who' as root on czplaptop. bash: /usr/bin/who: Permission denied Intercepting sub-commands Security Starts Here | One Identity - Restricted - Confidential
  • 33. • Visibility is not always good • Session recordings can include passwords Hiding passwords in recordings Security Starts Here | One Identity - Restricted - Confidential
  • 34. • Recordings are saved under /var/log/sudo-io/ • No sudo tool to display input • Files are compressed zless /var/log/sudo-io/00/00/01/ttyin passwd bla^Mblabla^Mblabla^M^D Hiding passwords in recordings Security Starts Here | One Identity - Restricted - Confidential
  • 35. • In /etc/sudoers: Defaults !log_passwords • Passwords are masked in session recordings: passwd bla^M********^M********^M^D Hiding passwords in recordings Security Starts Here | One Identity - Restricted - Confidential
  • 36. • The list pseudo-command allows regular users to list other user’s privileges • Audit without full admin access • Introduced in sudo version 1.9.13 bla ALL=(ALL) list Listing privileges
  • 37. bla@czplaptop:~> sudo -l bla's password: Matching Defaults entries for bla on czplaptop: always_set_home, secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin, env_reset, env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE", !insults, ignore_iolog_errors, log_output, log_input User bla may run the following commands on czplaptop: (ALL) list bla@czplaptop:~> sudo -U czanik -l Matching Defaults entries for czanik on czplaptop: always_set_home, secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin, env_reset, env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE", !insults, ignore_iolog_errors, log_output, log_input User czanik may run the following commands on czplaptop: (ALL) ALL List privileges
  • 38. • The long list (-ll) option now also prints the file name • Arrives in sudo version 1.9.15 List privileges
  • 39. leap154b:~ # sudo -U mytest -ll Matching Defaults entries for mytest on leap154b: always_set_home, secure_path=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin, env_reset, env_keep="LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE", insults, targetpw User mytest may run the following commands on leap154b: Sudoers entry: /etc/sudoers RunAsUsers: ALL Commands: ALL Sudoers entry: /etc/sudoers.d/foo RunAsUsers: root Commands: ALL List privileges
  • 40. • The file name and line number for the rule in the SOURCE filed of JSON-formatted logs • Arrives in sudo version 1.9.15 "source":"/etc/sudoers:66:23" "source":"/etc/sudoers.d/foo:1:15" SOURCE in JSON logs
  • 41. • Recent versions of sudo let you see and control a lot more activities: • More detailed, easier to use log messages • Log sessions through relays • Less need for root shells: chroot & cwd support • Track and intercept sub-commands • Password masking in logs • Listing privileges Summary Security Starts Here | One Identity - Restricted - Confidential
  • 42. • Sudo website: https://www.sudo.ws/ • My email: peter.czanik@oneidentity.com • Twitter: @Pczanik Questions?