Skip to content

[radius]: Use execl instead of popen in RADIUS NSS code to fix vulner…#277

Merged
gechiang merged 1 commit intoAzure:masterfrom
maipbui:cherrypick_radius
Mar 5, 2024
Merged

[radius]: Use execl instead of popen in RADIUS NSS code to fix vulner…#277
gechiang merged 1 commit intoAzure:masterfrom
maipbui:cherrypick_radius

Conversation

@maipbui
Copy link
Member

@maipbui maipbui commented Mar 3, 2024

…ability. (#15512)

ADO 27008044
Cherry-pick sonic-net/sonic-buildimage#15512

Why I did it
sonic-net/sonic-buildimage#15284 fixes a case of shell escape exploit for TACACS+. This applies to RADIUS as well. RADIUS creates an unconfirmed user locally on the switch while attempting authentication. popen() is used to execute useradd,usermod and userdel commands. This exposes a vulnerability where a tactically designed username (which could contain explicit linux commands) can lead to getting executed as root.

An example of such a username could be "asd";echo>remoteRCE2;#". This leads to remoteRCE2 getting created in "/".

How I did it
All calls to popen() used to execute useradd, usermod and userdel are replaced with fork()/execl().

How to verify it
Prior to the fix, following is the behavior:

[s@i vm] ssh "asd";echo>remoteRCE2;#"@1.1.1.1
asd";echo>remoteRCE2;#@1.1.1.1's password:
Permission denied, please try again.

On the SONiC switch,

root@sonic:/# ls
accton_as7816_monitor.log home lib64 remoteRCE2 sys
bin host libx32 root tmp
boot initrd.img media run usr
cache.tgz initrd.img.old mnt sbin var
dev lib opt sonic vmlinuz
etc lib32 proc srv vmlinuz.old
root@sonic:/# ls -l

With the fix:

[s@i vm] ssh "asd";echo>remoteRCE2;#"@1.1.1.1
asd";echo>remoteRCE2;#@1.1.1.1's password:
Permission denied, please try again.

root@sonic:/# ls
accton_as7816_monitor.log etc lib mnt sbin usr
bin home lib32 opt sonic var
boot host lib64 proc srv vmlinuz
cache.tgz initrd.img libx32 root sys vmlinuz.old
dev initrd.img.old media run tmp

Verified that RADIUS authentication works as expected for valid users as well.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

…ability. (#15512)

Why I did it
#15284 fixes a case of shell escape exploit for TACACS+. This applies to RADIUS as well. RADIUS creates an unconfirmed user locally on the switch while attempting authentication. popen() is used to execute useradd,usermod and userdel commands. This exposes a vulnerability where a tactically designed username (which could contain explicit linux commands) can lead to getting executed as root.

An example of such a username could be "asd";echo>remoteRCE2;#". This leads to remoteRCE2 getting created in "/".

How I did it
All calls to popen() used to execute useradd, usermod and userdel are replaced with fork()/execl().

How to verify it
Prior to the fix, following is the behavior:

[s@i vm] ssh "asd";echo>remoteRCE2;#"@1.1.1.1
asd";echo>remoteRCE2;#@1.1.1.1's password:
Permission denied, please try again.

On the SONiC switch,

root@sonic:/# ls
accton_as7816_monitor.log home lib64 remoteRCE2 sys
bin host libx32 root tmp
boot initrd.img media run usr
cache.tgz initrd.img.old mnt sbin var
dev lib opt sonic vmlinuz
etc lib32 proc srv vmlinuz.old
root@sonic:/# ls -l

With the fix:

[s@i vm] ssh "asd";echo>remoteRCE2;#"@1.1.1.1
asd";echo>remoteRCE2;#@1.1.1.1's password:
Permission denied, please try again.

root@sonic:/# ls
accton_as7816_monitor.log etc lib mnt sbin usr
bin home lib32 opt sonic var
boot host lib64 proc srv vmlinuz
cache.tgz initrd.img libx32 root sys vmlinuz.old
dev initrd.img.old media run tmp

Verified that RADIUS authentication works as expected for valid users as well.
@maipbui maipbui requested a review from qiluo-msft March 3, 2024 16:27
@qiluo-msft qiluo-msft requested a review from rlhui March 5, 2024 17:58
@gechiang gechiang merged commit e8d4861 into Azure:master Mar 5, 2024
@maipbui maipbui deleted the cherrypick_radius branch March 5, 2024 19:46
liushilongbuaa pushed a commit that referenced this pull request Dec 26, 2024
…lly (#19731)

#### Why I did it
src/sonic-gnmi
```
* 4e6f5b1 - (HEAD -> 202405, origin/202405) Merge pull request #277 from zbud-msft/revert_pfcwd_202405 (3 hours ago) [bingwang-ms]
* 547241a - Rerun pipeline (25 hours ago) [Zain Budhwani]
* 9785246 - Revert "Replace PFC_WD_TABLE with PFC_WD (#173)" (25 hours ago) [Zain Budhwani]
```
#### How I did it
#### How to verify it
#### Description for the changelog
bingwang-ms pushed a commit that referenced this pull request Jan 16, 2026
…utomatically (#23213)

#### Why I did it
src/sonic-host-services
```
* bcb34e2 - (HEAD -> master, origin/master, origin/HEAD) Fix ProcessStatsST column name issue and add test (#277) (5 days ago) [Feng-msft]
```
#### How I did it
#### How to verify it
#### Description for the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants