CARVIEW |
Select Language
HTTP/2 200
date: Fri, 25 Jul 2025 21:56:33 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/ksh93/ksh.git
etag: W/"9265babf0d23f7f2f587e6b1d920824f"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=D7RKefuwdtNZdsPHScLBlD7qhgyvGoY3pDYKjzzlC6Px5qmqs9SaVsR%2BrHNlJ9VfNwJAWDBRejhIDRygp3iVj17DUxeINZIaDOYxBaPQzYFPreB34FF8gt2YlC2uWylOfy0jD1Lcc76RUFB7Iy%2FaVPCAnhiZEuxPvS0Zd%2FHSv81oOUMPY9dUpjM1n1JRqn4Lf0MXebtuq55RJAG%2F7TLjEhun6Dg7pun8IvoHHXXBPr2vYY97AM%2FolrQaWsaOB3d7lcD4M%2BZLqLdIHwQfR%2FeJig%3D%3D--LmOCYJzi8Iop%2BmLP--qCsI3Tux5Mt%2FoZkMsu%2F4qA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.589355833.1753480592; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 21:56:32 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 21:56:32 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: B0A2:FB852:FE172:162C77:6883FD90
Fix arbitrary command execution/code injection bugs (#866) · ksh93/ksh@970812e · GitHub
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/shell.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/version.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/basic.sh
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/posix.sh
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit 970812e
authored
Fix arbitrary command execution/code injection bugs (#866)
* Security patch part 1
Never use $SHELL or sh.shpath when executing shebang-less scripts
- sh_ntfork(): Removed a misguided optimization that causes ksh to
run scripts without a shebang using the binary pointed to by
either $SHELL or sh.shpath. This has a few problems:
- The shell in sh.shpath or more disastrously in $SHELL has
no guarantee of being identical to the currently running
copy of ksh93 or even existing at all, so using either is
not only bogus, but potentially dangerous.
- The optimization has no ability to pass down the current
POSIX mode status to the script.
- It's only activated for virtual subshells, resulting in
arbitrarily different behavior depending on whether or
not we're in a virtual subshell.
- It does some weird stuff with /dev/fd that seems superfluous,
and also lacks any SHOPT_DEVFD if directive. (Additionally,
if it did have one, that stat(2) would likely become mere
dead code and a waste of context switches.)
The optimization was probably intended to be used for running a
shebang-less script via posix_spawn, which is ostensibly faster
than fork. But this simply isn't possible without risking running
the shebang-less script in a shell environment different from
the current one. (If ksh were updated by the package manager
while ksh is still running, this optimization would cause the
script to run via the new version, rather than the currently
running older version.) The optimization is unfixable by design,
and as such must be removed to ensure correct behavior.
* Security patch part 2 (re: bae02c3)
rm setuid script code leading to arbitrary command execution
Changes:
- Delete code for setuid scripts on "Solaris 2.5+" because it
allows for arbitrary command execution. One millisecond you think
you're launching ksh, the next you're at the mercy of a hijacker.
Example:
SHELL=/bin/ppmflash /bin/ksh -l /dev/fd/0 < <(true)
MANPATH: usage: MANPATH flashfactor [ppmfile]
flashfactor: 0.0 = original picture, 1.0 = total whiteout
The pathshell() code doesn't *seem* to be vulnerable to privilege
escalation, but who knows (cf. CVE-2019-14868; this might need its
own CVE 2025. Maybe pathshell() should be scrapped entirely???)
- Add fickle but functional regression test (you may need to pass
KSH=/bin/ksh or some such to get it to fail against vulnerable
versions of ksh). The test uses a login shell via the -l option,
but the bug *does not* need a login shell. See:
#874 (comment)
Modify the execveat reproducer to pass along environ (which
could include a hijacked SHELL), and you're in for a BAD time.
Maybe the deleted code (introduced sometime within the period of 1995
and 1999) was relevant to some Solaris-specific use case or something.
Maybe the erasure even causes an incompatibility. But that code must
go; it's far too dangerous to execv whatever the hell pathshell gives
us during **init**. (Need I bring CVE-2019-14868 back to remembrance
again? This bug has similarities to that one.)
FWIW, all of the regression tests in the ksh and modernish suites pass
with this patch applied.
* Security patch part 3
Delete pathshell() and replace uses of it with safer equivalents
This function is a dangerous attack vector that ought not remain
in the code base. The value returned by astconf() is doubtless
safer than what is returned by pathshell().
* Other changes
The libast pathprog function and prog feature test are now unused,
and are removed.1 parent 9e2e6ca commit 970812eCopy full SHA for 970812e
Expand file treeCollapse file tree
19 files changed
+53
-374
lines changed+17Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
5 | 22 |
| |
6 | 23 |
| |
7 | 24 |
| |
|
src/cmd/ksh93/include/shell.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/shell.h-3Lines changed: 0 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
225 | 225 |
| |
226 | 226 |
| |
227 | 227 |
| |
228 |
| - | |
229 |
| - | |
230 | 228 |
| |
231 | 229 |
| |
232 | 230 |
| |
| |||
269 | 267 |
| |
270 | 268 |
| |
271 | 269 |
| |
272 |
| - | |
273 | 270 |
| |
274 | 271 |
| |
275 | 272 |
| |
|
src/cmd/ksh93/include/version.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/version.h+1-1Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
| 21 | + | |
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
|
+1-33Lines changed: 1 addition & 33 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1266 | 1266 |
| |
1267 | 1267 |
| |
1268 | 1268 |
| |
1269 |
| - | |
1270 |
| - | |
1271 |
| - | |
1272 |
| - | |
1273 |
| - | |
1274 |
| - | |
1275 |
| - | |
1276 |
| - | |
1277 |
| - | |
1278 |
| - | |
1279 |
| - | |
1280 |
| - | |
1281 |
| - | |
1282 |
| - | |
1283 |
| - | |
1284 |
| - | |
1285 |
| - | |
1286 |
| - | |
1287 |
| - | |
1288 |
| - | |
1289 |
| - | |
1290 |
| - | |
1291 |
| - | |
1292 |
| - | |
1293 |
| - | |
1294 |
| - | |
1295 |
| - | |
1296 |
| - | |
1297 | 1269 |
| |
1298 | 1270 |
| |
1299 | 1271 |
| |
| |||
1306 | 1278 |
| |
1307 | 1279 |
| |
1308 | 1280 |
| |
1309 |
| - | |
1310 | 1281 |
| |
1311 | 1282 |
| |
1312 | 1283 |
| |
| |||
1318 | 1289 |
| |
1319 | 1290 |
| |
1320 | 1291 |
| |
1321 |
| - | |
1322 |
| - | |
1323 |
| - | |
1324 |
| - | |
| 1292 | + | |
1325 | 1293 |
| |
1326 | 1294 |
| |
1327 | 1295 |
| |
|
-21Lines changed: 0 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
221 | 221 |
| |
222 | 222 |
| |
223 | 223 |
| |
224 |
| - | |
225 |
| - | |
226 |
| - | |
227 |
| - | |
228 | 224 |
| |
229 | 225 |
| |
230 | 226 |
| |
231 | 227 |
| |
232 | 228 |
| |
233 | 229 |
| |
234 |
| - | |
235 |
| - | |
236 |
| - | |
237 |
| - | |
238 |
| - | |
239 |
| - | |
240 |
| - | |
241 |
| - | |
242 |
| - | |
243 |
| - | |
244 |
| - | |
245 |
| - | |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 |
| - | |
250 |
| - | |
251 | 230 |
| |
252 | 231 |
| |
253 | 232 |
| |
|
-2Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1221 | 1221 |
| |
1222 | 1222 |
| |
1223 | 1223 |
| |
1224 |
| - | |
1225 |
| - | |
1226 | 1224 |
| |
1227 | 1225 |
| |
1228 | 1226 |
| |
|
-20Lines changed: 0 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3365 | 3365 |
| |
3366 | 3366 |
| |
3367 | 3367 |
| |
3368 |
| - | |
3369 |
| - | |
3370 |
| - | |
3371 |
| - | |
3372 |
| - | |
3373 |
| - | |
3374 |
| - | |
3375 |
| - | |
3376 |
| - | |
3377 |
| - | |
3378 |
| - | |
3379 |
| - | |
3380 |
| - | |
3381 |
| - | |
3382 |
| - | |
3383 |
| - | |
3384 |
| - | |
3385 |
| - | |
3386 |
| - | |
3387 |
| - | |
3388 | 3368 |
| |
3389 | 3369 |
| |
3390 | 3370 |
| |
|
src/cmd/ksh93/tests/basic.sh
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/basic.sh+28Lines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1084 | 1084 |
| |
1085 | 1085 |
| |
1086 | 1086 |
| |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1087 | 1115 |
| |
1088 | 1116 |
|
src/cmd/ksh93/tests/posix.sh
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/posix.sh-2Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
81 | 81 |
| |
82 | 82 |
| |
83 | 83 |
| |
84 |
| - | |
85 | 84 |
| |
86 | 85 |
| |
87 | 86 |
| |
88 | 87 |
| |
89 | 88 |
| |
90 | 89 |
| |
91 | 90 |
| |
92 |
| - | |
93 | 91 |
| |
94 | 92 |
| |
95 | 93 |
| |
|
-21Lines changed: 0 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
322 | 322 |
| |
323 | 323 |
| |
324 | 324 |
| |
325 |
| - | |
326 |
| - | |
327 |
| - | |
328 |
| - | |
329 |
| - | |
330 | 325 |
| |
331 | 326 |
| |
332 | 327 |
| |
| |||
1222 | 1217 |
| |
1223 | 1218 |
| |
1224 | 1219 |
| |
1225 |
| - | |
1226 |
| - | |
1227 |
| - | |
1228 |
| - | |
1229 |
| - | |
1230 |
| - | |
1231 |
| - | |
1232 | 1220 |
| |
1233 | 1221 |
| |
1234 | 1222 |
| |
| |||
1238 | 1226 |
| |
1239 | 1227 |
| |
1240 | 1228 |
| |
1241 |
| - | |
1242 |
| - | |
1243 |
| - | |
1244 |
| - | |
1245 |
| - | |
1246 |
| - | |
1247 |
| - | |
1248 |
| - | |
1249 |
| - | |
1250 | 1229 |
| |
1251 | 1230 |
| |
1252 | 1231 |
| |
|
You can’t perform that action at this time.
0 commit comments