Previous Thread
Next Thread
Print Thread
XCALL B64ENC empty variable #37628 28 Oct 24 04:33 PM
Joined: Aug 2016
Posts: 371
J
John Andreasen Offline OP
Member
OP Offline
Member
J
Joined: Aug 2016
Posts: 371
Hi Jack,

I am not sure if there is actually a problem here, but I thought it was worth reporting. When attempting to base 64 encode an empty string that is passed to an X,0 (in the function wrapper calling XCALL B64ENC), it results in some random data being printed to the screen. If I manually copy the printed data out and base 64 decode, it appears to contain function names, variable names, etc. The function we are using is our own, but is fairly close to the SOSLIB Fn'B64'Encode'Buf$() implementation. I say that I am not sure if it's actually a problem because it seems like you shouldn't be trying to encode an empty string. Perhaps the function should check and never let the call to XCALL B64ENC happen? Anyway, I have attached an LSX of a test program that can demonstrate this if you want to take a look. It can be reproduced with A-Shell 7.0.1762.4 on EL7.

Thanks,
John Andreasen
Diversified Data Software

Attached Files
testbase64.txt (5.26 KB, 15 downloads)
SHA1: b5f887e2923eea400e3b03678efa90535474196f
Re: XCALL B64ENC empty variable [Re: John Andreasen] #37629 28 Oct 24 06:31 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794
Hi John,

You've hit the daily double, triggering two unrelated loopholes together with a single line of code to crack open a security breach! You might want to go buy a lottery ticket while you've got the magic touch...

The initial loophole was the result of an oversight in the B64ENC parameter design, where the flag parameter is used to determine whether the indata parameter is a filespec or a memory buffer, assuming that a size of 0 must indicate that its a file (since why would anyone want to encode an empty string?) confused

The second loophole was A-Shell's filespec conversion-to-native function was failing to clear the output in the case of an empty input spec. It returns an error code, but since that scenario is so rare, calling routines often just proceed directly to using the translated filespec (assuming any errors could then be dealt with). But in this case, B64ENC was using the global last-translated-filespec variable for the translated filename, (a useful shortcut for file-related error handling). So the end result was that instead of encoding your empty string, it was encoding the last processed filespec probably your RUN file, or maybe an SBX). (It's a good thing you found this before the Russians did! cool)

Anyway, I believe it's all patched up in 1764.1 ...

ash-7.0.1764.1-el7-upd.tz
ash-7.0.1764.1-el7-x86_64-upd.tz
ash70notes.txt

Re: XCALL B64ENC empty variable [Re: John Andreasen] #37630 28 Oct 24 06:52 PM
Joined: Aug 2016
Posts: 371
J
John Andreasen Offline OP
Member
OP Offline
Member
J
Joined: Aug 2016
Posts: 371
Wow, very interesting. Thanks Jack. I am glad it resulted in a worthwhile fix. I'll download the new version and give it a try.

Re: XCALL B64ENC empty variable [Re: John Andreasen] #37631 28 Oct 24 08:40 PM
Joined: Aug 2016
Posts: 371
J
John Andreasen Offline OP
Member
OP Offline
Member
J
Joined: Aug 2016
Posts: 371
All seems to be fixed here. Now to update everyone before the hackers read this and figure it out... wink

Re: XCALL B64ENC empty variable [Re: John Andreasen] #37632 28 Oct 24 09:39 PM
Joined: Nov 2006
Posts: 2,223
S
Stephen Funkhouser Offline
Member
Offline
Member
S
Joined: Nov 2006
Posts: 2,223
Jack, could you build a Debian 12 variant? Thanks!


Stephen Funkhouser
Diversified Data Solutions
Re: XCALL B64ENC empty variable [Re: John Andreasen] #37633 29 Oct 24 12:29 AM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3