Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.subtle.importKey results in Segmentation fault if given an invalid key #9088

Closed
arshia-gh opened this issue Feb 24, 2024 · 2 comments
Closed
Labels
bug Something isn't working crash An issue that could cause a crash windows An issue that is known to occur on Windows

Comments

@arshia-gh
Copy link

What version of Bun is running?

1.0.28

What platform is your computer?

MINGW64_NT-10.0-22621 3.3.5-341.x86_64 x86_64 unknown (WSL)

What steps can reproduce the bug?

an invalid PK

const myPk = Buffer.alloc(65).fill(0);

call the importKey function with the invalid key

crypto.subtle.importKey(
	'raw',
	myPk,
	{
	    name: 'ECDSA',
	    namedCurve: 'P-256',
        },
	true,
	['verify']
);

What is the expected behavior?

Some sort of JS Exception to be able to handle the error

What do you see instead?

Segmentation fault at address 0x8
???:?:?: 0x7ff6e2674cc6 in ??? (bun.exe)
???:?:?: 0x7ff6e2937fc4 in ??? (bun.exe)
???:?:?: 0x7ff6e293813e in ??? (bun.exe)
???:?:?: 0x7ff6e27c5645 in ??? (bun.exe)
???:?:?: 0x7ff6e261aa49 in ??? (bun.exe)
???:?:?: 0x7ff6e261ac28 in ??? (bun.exe)
???:?:?: 0x7ff6e4056f14 in ??? (bun.exe)
???:?:?: 0x7ff6e401f0fa in ??? (bun.exe)
???:?:?: 0x7ff6e4025e24 in ??? (bun.exe)
???:?:?: 0x7ff6e40921fd in ??? (bun.exe)
???:?:?: 0x7ff6e3fcc698 in ??? (bun.exe)
???:?:?: 0x7ff6e40a2ee6 in ??? (bun.exe)
???:?:?: 0x1ad02b0 in ??? (???)
???:?:?: 0x1f in ??? (???)
???:?:?: 0x1bde91ec2af in ??? (???)

Additional information

No response

@arshia-gh arshia-gh added the bug Something isn't working label Feb 24, 2024
@arshia-gh
Copy link
Author

I can also confirm the bug is not caused by the initial bit being 0

the following input results in the same error

Buffer(65) [ 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]

@Jarred-Sumner Jarred-Sumner added the windows An issue that is known to occur on Windows label Feb 24, 2024
@Electroid Electroid added the crash An issue that could cause a crash label Feb 27, 2024
@nektro
Copy link
Contributor

nektro commented Aug 15, 2024

this now reports an error as expected

DataError: Data provided to an operation does not meet requirements
      at c:\bun\test.js:2

Bun v1.1.24-debug (Windows x64)

@nektro nektro closed this as completed Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash windows An issue that is known to occur on Windows
Projects
None yet
Development

No branches or pull requests

4 participants