Title: ffi: No interior NULs (part 1) by joshuamegnauth54 · Pull Request #8245 · RustPython/RustPython · GitHub
Open Graph Title: ffi: No interior NULs (part 1) by joshuamegnauth54 · Pull Request #8245 · RustPython/RustPython
X Title: ffi: No interior NULs (part 1) by joshuamegnauth54 · Pull Request #8245 · RustPython/RustPython
Description: (This is WIP; the Windows code doesn't even compile yet 😆 Opening as placeholder + CodeRabbit lints ) Interior NULs is a security hazard for C-style strings. A NUL byte truncates a string which can lead the caller and callee to see two different strings. It can cause path traversal attacks where a path in Python looks complete but it is interpreted differently through FFI. RustPython needs to handle this for some of its C-API as well as raw libc or Windows calls. Both Rust's standard library as well as Rustix handle interior NULs for us with CStrings, so this mostly affects Windows or areas where we have raw bytes that weren't checked by CString. Finally, this PR is non-exhaustive. I will have to rely heavily on CodeRabbit to help lint it to ensure that interior NUL checks are only introduced for FFI and not outside of it. Most of RustPython seems to handle interior NULs already due to CString as well as WideCString. AI disclosure: I relied on AI to ensure I'm solving this problem correctly. Mainly, I used it to check if the FFI functions I'm modifying need to handle interior NULs. Sources: https://owasp.org/www-community/attacks/Embedding_Null_Code python/cpython#111656 Assisted-by: Codex:gpt-5.4 Closes #xxxx This PR follows our AI policy Summary Summary by CodeRabbit Bug Fixes Improved Windows path, registry, networking, and environment-variable handling. Embedded null characters in strings are now detected consistently and reported as clear Python errors instead of being silently mishandled. Wide-character conversions now validate input and propagate failures safely. Improved Windows file-extension detection for executable-related behavior. Refactor Standardized string conversion and null-termination behavior across platform integrations.
Open Graph Description: (This is WIP; the Windows code doesn't even compile yet 😆 Opening as placeholder + CodeRabbit lints ) Interior NULs is a security hazard for C-style strings. A NUL byte truncates a string which...
X Description: (This is WIP; the Windows code doesn't even compile yet 😆 Opening as placeholder + CodeRabbit lints ) Interior NULs is a security hazard for C-style strings. A NUL byte truncates a string w...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8245
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fc4deed5-6ab0-20ca-d707-bf2ddbf19b2f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D992:2C555C:8010D8:A914D6:6A5B9E61 |
| html-safe-nonce | e01675bb880dc6f75e4103560a6e1a60df21e57fc9d14fda4602fe7bd81b83a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTkyOjJDNTU1Qzo4MDEwRDg6QTkxNEQ2OjZBNUI5RTYxIiwidmlzaXRvcl9pZCI6IjQyMjM3OTExMTU4MTQ1ODAxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 97ecfa7bcbddd57e82293d212f500c6ff47cfa37e993771a5cdaf9832ce066fc |
| hovercard-subject-tag | pull_request:4018763228 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/8245/files |
| twitter:image | https://avatars.githubusercontent.com/u/48846352?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/48846352?s=400&v=4 |
| og:image:alt | (This is WIP; the Windows code doesn't even compile yet 😆 Opening as placeholder + CodeRabbit lints ) Interior NULs is a security hazard for C-style strings. A NUL byte truncates a string which... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width