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

Error: 140735127326720:error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac #4161

Closed
santigimeno opened this issue Dec 4, 2015 · 17 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. confirmed-bug Issues with confirmed bugs. tls Issues and PRs related to the tls subsystem.

Comments

@santigimeno
Copy link
Member

With latest master, I was trying to track down some flakiness in test-tls-inception.js, so I increased the data sent from the socket at the b server like this:

diff --git a/test/parallel/test-tls-inception.js b/test/parallel/test-tls-inception.js
index df03cf9..4dc885d 100644
--- a/test/parallel/test-tls-inception.js
+++ b/test/parallel/test-tls-inception.js
@@ -38,7 +38,7 @@ a = tls.createServer(options, function(socket) {

 // the "target" server
 b = tls.createServer(options, function(socket) {
-  socket.end('hello');
+  socket.end((new Buffer(4000)).fill('a'));
 });

 process.on('exit', function() {

and got this error:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: 140735127326720:error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:../deps/openssl/openssl/ssl/s3_pkt.c:532:

    at Error (native)

Reducing the size of the Buffer to 3000 does not cause the error. Is this expected or a bug?

Thanks

@silverwind silverwind added the tls Issues and PRs related to the tls subsystem. label Dec 4, 2015
@jhamhader
Copy link
Contributor

I began investigating this one.
It happens with a buffer or string size >= 3810 and write() also triggers it.

@mscdex
Copy link
Contributor

mscdex commented Dec 8, 2015

Ok, so it looks like the cleartext data is probably getting mixed with the underlying TLS exchange somehow (hence the protocol error). To verify this, if you wait until you see the secureConnect event of the second tls.connect() to do socket.end(message); in TLS server b, it will work just fine (you can accomplish this using an event emitter or calling a function that gets set inside b's connection handler that wraps socket.end(message);). Alternatively, wrap the socket.end(message); in a setTimeout() of like 1 second or so for the same effect.

@mscdex
Copy link
Contributor

mscdex commented Dec 8, 2015

/cc @indutny

@indutny
Copy link
Member

indutny commented Dec 8, 2015

Will look into this tomorrow.

@indutny
Copy link
Member

indutny commented Dec 8, 2015

Actually, I have a fix for it right now.

indutny added a commit to indutny/io.js that referenced this issue Dec 8, 2015
Fix incorrect slicing of cleartext buffer in `TLSWrap::ClearOut`.

Fix: nodejs#4161
@indutny
Copy link
Member

indutny commented Dec 8, 2015

Here you go #4184 . Thanks for figuring it out!

@indutny indutny added confirmed-bug Issues with confirmed bugs. c++ Issues and PRs that require attention from people who are familiar with C++. labels Dec 8, 2015
@indutny indutny closed this as completed in c0cb80e Dec 8, 2015
@indutny
Copy link
Member

indutny commented Dec 8, 2015

Fixed!

indutny added a commit that referenced this issue Dec 9, 2015
Fix incorrect slicing of cleartext buffer in `TLSWrap::ClearOut`.

Fix: #4161
PR-URL: #4184
Reviewed-By: Brian White <mscdex@mscdex.net>
indutny added a commit that referenced this issue Dec 30, 2015
Fix incorrect slicing of cleartext buffer in `TLSWrap::ClearOut`.

Fix: #4161
PR-URL: #4184
Reviewed-By: Brian White <mscdex@mscdex.net>
MylesBorins pushed a commit that referenced this issue Jan 19, 2016
Fix incorrect slicing of cleartext buffer in `TLSWrap::ClearOut`.

Fix: #4161
PR-URL: #4184
Reviewed-By: Brian White <mscdex@mscdex.net>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
Fix incorrect slicing of cleartext buffer in `TLSWrap::ClearOut`.

Fix: nodejs#4161
PR-URL: nodejs#4184
Reviewed-By: Brian White <mscdex@mscdex.net>
@vongohren
Copy link

I recieved this today on my heroku server: Aug 23 06:00:00 0c5e4c77-c2c9-445d-aff8-3564937f7520 comicFeed: error We’ve encountered an error: Error: 140094844344192:error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:../deps/openssl/openssl/ssl/s3_pkt.c:535:

The server is running node 7.10
But I dont have much else to go on.

@Trott
Copy link
Member

Trott commented Aug 23, 2017

The server is running node 7.10

@vongohren 7.x is unsupported. If you can, consider upgrading to 8.x (which will be supported until the end of 2019). No idea if this will fix your issue, but it's the first thing I'd try.

@petermetz
Copy link

Just received this on macOS Mojave running Node 8, please see details below:

Error: 4571538880:error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:../deps/openssl/openssl/ssl/s3_pkt.c:535:
openssl version
OpenSSL 1.0.2l  25 May 2017
node --version
v8.15.1

@sam-github
Copy link
Contributor

@petermetz You are using openssl 1.0.2l, but node 8.15.1 uses openssl 1.0.2r. You should ensure that this isn't specific to your non-standard build. Also, the bug fixed here has been backported to 8.15.1, as far as I can see from a quick check, so you should report this as a different bug. It would help to have a reproduction.

@satendrasingh51
Copy link

@sam-github @mscdex @silverwind @indutny @Trott
same error on all dependence installation

npm ERR! code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! 8896:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Satendra singh\AppData\Local\npm-cache\_logs\2021-12-11T05_34_29_970Z-debug.log

@Trott
Copy link
Member

Trott commented Dec 11, 2021

@sam-github @mscdex @silverwind @indutny @Trott same error on all dependence installation

npm ERR! code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! 8896:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Satendra singh\AppData\Local\npm-cache\_logs\2021-12-11T05_34_29_970Z-debug.log

What version of Node.js are you running?

@satendrasingh51
Copy link

satendrasingh51 commented Dec 12, 2021

@sam-github @mscdex @silverwind @indutny @Trott same error on all dependence installation

npm ERR! code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! 8896:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Satendra singh\AppData\Local\npm-cache\_logs\2021-12-11T05_34_29_970Z-debug.log

What version of Node.js are you running?

Node version is 14,
I have updated node version right now 16,

And in node js version 16

Error is

npm ERR! code ERR_SSL_CIPHER_OPERATION_FAILED
npm ERR! errno ERR_SSL_CIPHER_OPERATION_FAILED
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/react-scripts: 3C160000:error:1C800066:Provider routines:ossl_gcm_stream_update:cipher operation failed:c:\ws\deps\openssl\openssl\providers\implementations\ciphers\ciphercommon_gcm.c:312:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ss719\AppData\Local\npm-cache\_logs\2021-12-12T10_20_04_982Z-debug.log

@Trott
Copy link
Member

Trott commented Dec 12, 2021

Sounds like a network/firewall/proxy problem. If you're on WiFi, maybe try moving to another network.

@satendrasingh51
Copy link

But on network change this error
npm ERR! Cannot read properties of undefined (reading 'isServer')

@Trott
Copy link
Member

Trott commented Dec 12, 2021

But on network change this error npm ERR! Cannot read properties of undefined (reading 'isServer')

Maybe try npm cache clear --force. If that doesn't work, you can try the npm issue tracker , the Node.js help repo, StackOverflow, #node.js channel on libera.chat, or Node.js Slack Community (register at nodeslackers.com). This seems unlikely to be a Node.js core bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. confirmed-bug Issues with confirmed bugs. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

No branches or pull requests

10 participants