TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

OpenBSD now enforcing no invalid NUL characters in shell scripts

185 pointsby CTOSian8 months ago

22 comments

amiga3868 months ago
Here&#x27;s the actual diff:<p><a href="https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;cgi-bin&#x2F;cvsweb&#x2F;src&#x2F;bin&#x2F;ksh&#x2F;shf.c.diff?r1=1.34&amp;r2=1.35" rel="nofollow">https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;cgi-bin&#x2F;cvsweb&#x2F;src&#x2F;bin&#x2F;ksh&#x2F;shf.c....</a><p>And it looks like that covers all parsed parts of the shell script or history file, <i>including heredocs</i>. I get the feeling it&#x27;s going to break all shar archives with binary files (not that they&#x27;re particularly common). It will stop NULs being in the script itself, but it won&#x27;t stop them coming from other sources, e.g.<p><pre><code> $ var=$(printf &#x27;\0hello&#x27;) -bash: warning: command substitution: ignored null byte in input $ echo $var hello </code></pre> It remains to be seen if this will be adopted by anyone else, or if it&#x27;ll be another reason to use OpenBSD only as a restricted environment and not as a general computing platform.<p>&gt; &quot;If there is ONE THING the Unix world needs, it is for bash&#x2F;ksh&#x2F;sh to stop diverging further&quot;<p>&gt; OpenBSD ksh: <i>diverges further</i>
评论 #41638588 未加载
评论 #41637242 未加载
评论 #41651448 未加载
评论 #41643811 未加载
评论 #41639473 未加载
mcculley8 months ago
&quot;We are in a post-Postel world&quot; is a great way to put it. This needs to be repeated by everyone working with file formats or accepting untrusted input.
评论 #41637320 未加载
评论 #41636598 未加载
评论 #41636611 未加载
评论 #41639709 未加载
评论 #41637958 未加载
jrockway8 months ago
I like the term post-Postel.<p>There are two reliability constraints that all software faces; security and interoperability. The more lax you are about validation, the more likely interoperability is. &quot;That&#x27;s weird, I&#x27;ll just do whatever&quot; is doing SOMETHING, and it&#x27;s often to the end user&#x27;s liking. But, you also enter a more and more undefined state inside the software on the other side, and that&#x27;s where weird things happen. Weird things happening typically manifest as security problems. So the more effort you go to to minimize the possibility of entering a weird state, the more confidence you have that your software is working as specified.<p>Postel&#x27;s Law made a lot of sense to me when developing the early Internet. A lot of people were reading imperfect RFCs, and it was nice when your HP server could communicate with a Sun workstation, even though maybe some bit in the TCP header was set wrong. But now? You just gotta get it right and push a hotfix when you realize you messed something up. (Sadly, I don&#x27;t think it&#x27;s possible. Middleboxes are getting more and more popular. At work, we make a product where the CLI talks to the server over HTTP&#x2F;2. We also install Zscaler on every workstation. Zscaler simply blocks HTTP&#x2F;2. So you can&#x27;t use our product. Awkward.)
评论 #41639821 未加载
评论 #41642142 未加载
saagarjha8 months ago
&gt; There appears to be one piece of software which is misinterpreting guidance of this, and trying to depend upon embedded NUL.<p>Curious what this is
评论 #41636616 未加载
sneela8 months ago
&gt; This was in snapshots for more than 2 months, and only spotted one other program depending on the behaviour (and that test program did not observe that it was therefore depending in incorrect behaviour!!)<p>Fascinating. I wonder what that program is, and why it depends on the NUL character.
bell-cot8 months ago
Kudos to OpenBSD!<p>Similar to the olde-tyme &quot;-o noexec&quot; and &quot;-o nosuid&quot; options for `mount`, there should be easy, no-exceptions ways to blanket ban other types of simply obvious red-flag activity.
parasense8 months ago
Is this going to murder those fancy shell scripts that self-extract a program appended to the tail, which is really just an encoded blob of some kind, presumably compressed, etc.. ???
评论 #41638839 未加载
chasil8 months ago
I was going to check the status of mksh (the Android system shell), but the project page returns:<p>&quot;Unavailable For Legal Reasons - Sorry, no detailled error message available.&quot;<p><a href="http:&#x2F;&#x2F;www.mirbsd.org&#x2F;mksh.htm" rel="nofollow">http:&#x2F;&#x2F;www.mirbsd.org&#x2F;mksh.htm</a><p>The Android system shell is now abandoned? This is also in rhel9 basesos.
评论 #41636513 未加载
评论 #41638875 未加载
评论 #41636582 未加载
评论 #41637414 未加载
评论 #41636718 未加载
评论 #41636605 未加载
评论 #41637434 未加载
chrisfinazzo8 months ago
Related: The installer for iTunes 12.2.1 included a bug which might recursively delete a volume if the path given as input included incorrectly escaped spaces.
评论 #41637944 未加载
Taikonerd8 months ago
On a similar note, I sometimes think about how newline characters are allowed in filenames, and how that can break simple...<p><pre><code> for each $filename in `ls` </code></pre> loops -- because in many contexts, UNIX treats newlines as a delimiter.<p>Is there any legitimate use for filenames with newlines?
评论 #41636972 未加载
评论 #41637287 未加载
评论 #41636856 未加载
评论 #41636784 未加载
评论 #41637381 未加载
评论 #41639178 未加载
whiterknight8 months ago
Side note: tell your startup to switch its “hardware with Ubuntu Linux inside” to BSD. You will have a much more stable and simple platform that can last a long time.
评论 #41638794 未加载
raverbashing8 months ago
&gt; There appears to be one piece of software which is misinterpreting guidance of this, and trying to depend upon embedded NUL.<p>Big oof here. Why? How?<p>&gt; If there is ONE THING the Unix world needs, it is for bash&#x2F;ksh&#x2F;sh to stop diverging further by permitting STUPID INPUT that cannot plausibly work in all other shells. We are in a post-Postel world.<p>Amem
opk8 months ago
I&#x27;ve always found the fact that zsh copes with NUL characters in variables etc to be really useful. I can see why this approach makes sense for OpenBSD but they can&#x27;t prevent NULs appearing in certain places like piped input.
lupusreal8 months ago
Does this break those self-extracting script&#x2F;tar files? I forget how those are done, I haven&#x27;t seen one in many years.
评论 #41636378 未加载
评论 #41637847 未加载
评论 #41636501 未加载
评论 #41637753 未加载
klooney8 months ago
Does this break the self extracting tarball trick, where you have a bootstrap shell script with a binary payload appended?
评论 #41639123 未加载
nubinetwork8 months ago
So I can&#x27;t bury a tarball inside a shell script anymore?
评论 #41636340 未加载
评论 #41636355 未加载
soupbowl8 months ago
I wish FreeBSD replaced &#x2F;bin&#x2F;sh with OpenBSDs.
评论 #41637185 未加载
chmorgan_8 months ago
Wow, they still use CVS...
评论 #41718498 未加载
enriquto8 months ago
Great. Now forbid spaces in filenames.
评论 #41640494 未加载
sph8 months ago
Is this in reference to something? Judging from the comments, NUL bytes in shell scripts are a common occurrence that everybody is celebrating this change as if it were ground breaking.<p>I mean, it&#x27;s a good idea, but I wonder what am I missing here. Also what do they mean by post-Postel?
评论 #41636673 未加载
评论 #41636653 未加载
评论 #41636641 未加载
2snakes8 months ago
Surprised noone has mentioned the Crowdstrike issue, which was due to NUL characters wasn&#x27;t it?
评论 #41649381 未加载
0xbadcafebee8 months ago
<p><pre><code> &gt; If there is ONE THING the Unix world needs, it is for bash&#x2F;ksh&#x2F;sh to &gt; stop diverging further by permitting STUPID INPUT that cannot &gt; plausibly work in all other shells. We are in a post-Postel world. &gt; &gt; It remains possible to put arbitrary bytes *AFTER* the parts of the &gt; shell script that get parsed &amp; executed (like some Solaris patch files &gt; do). But you can&#x27;t put arbirary bytes in the middle, ahead of shell &gt; script parsed lines, because shells can&#x27;t jump to arbitrary offsets &gt; inside the input file, they go THROUGH all the &#x27;valid shell script &gt; text lines&#x27; to get there. So here it is again, an example of OpenBSD making software behavior saner for all of us. </code></pre> I don&#x27;t consider use of all caps over a minor issue to be sane behavior. At best it&#x27;s immaturity (trying to force your point rather than persuade), and at worst it&#x27;s an emotional imbalance that effects judgement. That said, it&#x27;s ksh, on OpenBSD, so I couldn&#x27;t care less what they do.
评论 #41640945 未加载