question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attempt to write outside buffer bounds

See original GitHub issue

Expected Behavior I want to extract an asar file using asar extract app.asar command.

Actual Behavior I get the following error: RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds

To Reproduce Run asar extract app.asar command on asar file.

Screenshots https://i.imgur.com/zmNOSqq.png

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:15
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
maleptcommented, Feb 18, 2020

Can someone please provide a minimal testcase for this?

2reactions
AxDSancommented, Mar 29, 2020

The error “attempted to write outside buffer bounds” means exactly that, when attempting to write to the buffer it went outside its capacity, meaning it got past the amount of elements of what it’s supposed to have. In this case CocosCreator ASAR has been packed in such a way that it doesn’t even read properly the file because the contents have been encrypted.

The unpacking process of the ASAR files starts from the very beginning, of course… The extractor needs to read the headers first and then verify its contents, like where each file is (you can read more about ASAR file format here: ASAR Format) afterwards, it just proceeds to unpack the file given its header information.

Going back to the discussion, as per example:

Asar’s transform option allows to specify a stream transformer that is applied when the files are packed into the asar container. However at some point you will have to decrypt your files and this is where it gets really tricky. Also, if your static password leaks you’re not winning anything.

const crypto = require('crypto')
var password = new Buffer(‘my secret password’);
function transform(filename) {
 return crypto.createCipher(‘aes-256-cbc’, password);
}
asar.createPackageWithOptions(src, dest, { transform: transform }..)

this means they have packaged their application with a specific transformation option that may have probably encrypted the contents of the headers… since when you open the file only the header is encrypted, and not the actual file contents, or even the names, which if you ask me if quite a smart thing to do!👌

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempt to write outside buffer bounds" · Issue #7047 · ...
I've had multiple users report a RangeError: Attempt to write outside buffer bounds error that originates inside the Buffer constructor. Here's ...
Read more >
MongoDB RangeError: attempt to write outside buffer bounds
Any idea when MongoDB throws RangeError: attempt to write outside buffer bounds? Please suggest. Below method insert the data in Mongodb
Read more >
API "Attempt to write outside buffer bounds"
Hi,When I use the API with:GET /outbreaks/{id}/relationships/exportIt gives the following error: "Attempt to write outside buffer bounds"Do you know why?
Read more >
Buffer out of bounds error when reading empty byte buffers
Buffer out of bounds error when reading empty byte buffers. 162 views ... RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds.
Read more >
Using rules to query MySQL, Attempt to access memory ...
You should be able to make external API calls from rules provided you have whitelisted the auth0 ... Attempt to write outside buffer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found