Same Azure Function, same input, different tenant, different output

Viewed 72

Stumped as to where to go next with this issue.

My node.js azure function takes in a file represented as base64. It does some processing on the file and returns the processed file in the response:

module.exports = async function (context, req) {

    const buf = Buffer.from(req.body.file, 'base64')

    /// do processing

    const file = filebuf.toString('base64')

    context.res.status(200).json({ file })
}

So in my personal Azure tenant this works fine. In my clients azure tenant, the file is corrupted. This is with the same exact file as input.

Not sure if its interesting but the first few bytes of the different tenants processed files are as so:

{
    "file": "UEsDBAoAAAAAAGh+r1SoFh7uRAwAAEQMAAA..."
}



{
    "file": "UEsDBAoAAAAAANh8r1SoFh7uRAwAAEQMAAA..."
}

For some reason, around the 14th char is different and I can't think why that would be. Both function apps are running on Linux and the runtime version of the apps are the same.

Thanks

EDIT:

Following the first answer and my new understanding that the different byte is to be expected I am still not closer to understanding why one file is corrupt and another is not.

I now notice that the content length of the body is different:

Non-corrupt:

"headers":{"Transfer-Encoding":"chunked","Vary":"Accept-Encoding","Strict-Transport-Security":"max-age=31536000; includeSubDomains","x-ms-apihub-cached-response":"true","x-ms-apihub-obo":"true","Cache-Control":"private","Date":"Mon, 16 May 2022 08:25:38 GMT","Content-Type":"application/json; charset=utf-8","Content-Length":"2926356"}

Corrupt:

"headers":{"Transfer-Encoding":"chunked","Request-Context":"appId=cid-v1:XXX","x-ms-apihub-cached-response":"true","x-ms-apihub-obo":"true","Date":"Mon, 16 May 2022 08:24:48 GMT","Content-Type":"application/json; charset=utf-8","Content-Length":"2926368"}

Where could these extra bytes have come from? I wondering if it might be between different versions of Node but would be surprised.

1 Answers

The 2 bytes which are different are part of the ZIP file header and describe the modification time.

Let's take a look at the first partial base64 string

base64
UEsDBAoAAAAAAGh+r1SoFh7uRAwAAEQMAAA

hex
50 4b 03 04 0a 00 00 00 00 00 68 7e af 54 a8 16 1e ee 44 0c 00 00 44 0c 00 00

The first 4 bytes 50 4b 03 04 are the ZIP file signature, 0a 00 the version, 00 00 the flags, 00 00 the compression method and finally 68 7e the file modification time. This is in MS-DOS format which translates to 13:03:15. Needless to say the different time values in there do not indicate a corrupted file.

More information on the ZIP format: https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html

Related