-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
[0.28.1] Node16 on Alpine suffers SIGSEGV error when using argon2 verify #302
Comments
Hello, any update on this ? Got the same problem today on node 16 running on alpine linux with the 0.28.3 package version. |
Can confirm the issue. Downgrading to v0.27.2 solves it temporarily. |
I can reproduce it, but I could not isolate the root cause yet Edit: just found it. Seems to be related to Blake2 secure memory wipe from Argon2. Will try to work around that. Backtrace for anyone interested:
|
This seems to be a problem that occurs when the version of Node.js is different between build and runtime. Alpine Linux is built with Node 14, so the error occurs with Node 16. The solution is to run the build in source with the ARG NODE_VERSION=16.2.0
###
# 1. Dependencies
###
# Build with alpine linux
FROM node:${NODE_VERSION}-alpine as dependencies
WORKDIR /home/node/
ENV NODE_ENV development
# Add `build from source` flag
ENV npm_config_build_from_source true
# Install the tools needed for the build
RUN apk add make g++ python3 git
RUN npm i -g node-pre-gyp
COPY tsconfig.json package.json *package-lock.json ./
RUN npm ci
COPY ts ./ts
# "prod-build" on production
RUN npm run setup && \
npm prune --production
###
# 2. Application
###
FROM node:${NODE_VERSION}-alpine
WORKDIR /home/node/
COPY --from=dependencies /home/node/node_modules node_modules
COPY --from=dependencies /home/node/built built
COPY package.json ./
ENV PATH="$PATH:/home/node/node_modules/.bin"
RUN chown -R node:node /home/node
USER node
ENV NODE_ENV production
# "start" on production
CMD ["npm", "run", "start"] |
Interestingly, this seems to be only happening with Alpine. I can understand why it happens, but I was expecting |
Getting same error...tried everything I could think of...alpine image fails...node image fails...version 0.27.2 fails...anyone knows why it fails?
project url https://github.com/testtestingtester/zombies-angular-nestjs |
@testtestingtester the project you sent does not seem to use this library. Additionally, you are not using Alpine, you are using With that said, can you check the latest version (0.30.2)? |
node:16 in the code I pasted but I tried with alpine different versions also, you want me to copy paste those configs? i think not...I'll try 0.30.2 but I'm thinking it's hopeless and probably won't work like the rest I tried...works on mac though |
same error even with 0.30.2, i tried downgrading actually because I saw that was the fix others were saying...the project doesn't have the configs in the repo yet but if you try to add them and run |
using |
Possibly getting the same error here: /home/runner/work/code-server/code-server/node_modules/argon2/lib/binding/napi-v3/argon2.node: invalid ELF header
at Runtime._loadModule (test/node_modules/jest-runtime/build/index.js:1180:29)
at Object.<anonymous> (node_modules/argon2/argon2.js:6:25) Using |
Hi, Do you know if we have any updates here? I have the same problem with the latest version of |
I just saw this for the first time I can ever recall using Regrettably my scrollback is too small and the error is already gone so I can't see if it was identical to @jsjoeio. We're running Ubuntu 22.10. |
Just hit it again. We're downgrading to If I don't report the issue anymore, it's probably safe to assume the issue is |
@slapbox I believe you have a different problem than the one in this issue. This one is caused by/within musl so unless it's happening in Alpine or Void it's not the same thing :P |
It's been some time since I reported this issue and unfortunately it's still a valid issue. Compared to 2021, we're currently using:
The only reason I'm bumping this issue is because of the security update introduced through 0.31.0 which we cannot update to without changing to another underlying linux distro or replacing argon2 entirely (which I'd really want to avoid if possible). Is there anything I can do to help resolve this issue in the near future? |
@Tallyrald it would be good if you can get the Alpine developers' attention on this issue, it's super hard to debug and when I traced the exception, it happens inside musl, so it's not something we can change from node-argon2 A bug report on their tracker should be enough to get the ball rolling. |
this happens because the there is nothing alpine (or musl) can do to fix this. it works if you rebuild it:
|
the reason it sometimes happens to work is because musl has some degree of compatibility with glibc (ABI-wise), but it is neither complete nor guaranteed to work (so the older versions just so happened to only use the C api in such a way as to be compatible with either). and when it doesn't match up, having a different ABI than what you compiled against just crashes. there is nothing to do about that (in either alpine, musl, or this repository; though one could argue npm should better handle precompiled binary files and have easy ways to forbid ones that wouldn't work, like how python wheels only install on matching platforms and require building otherwise). |
The precompiled binary will be linked against musl if you are running Alpine. The problem with the Dockerfile provided in this issue is that it installs dependencies under Debian, but then copies to Alpine and does not perform the install step again to refetch the precompiled binary. |
in that case it would work fine, indeed this specific way of installing it would be broken :) |
yeah, can confirm changing |
Thank you @nekopsykose and @ranisalt for your help. For my specific needs the final solution is to run a 2-step pre-build process before copying everything over to the final image.
For me, the problem is resolved now. If this is satisfactory for others too, please close this issue. Just for reference, I asked for help in the Alpine issues board HERE which helped the issue move forward and be solved. |
@Tallyrald why do you need to run it on Debian? Doesn't Alpine provide the tools you need to build this project? |
We have at least one 3rd party library that doesn't support building on Alpine. Heck it didn't even use to run on Alpine, but that got solved some years ago. I wish I knew why this is, but I'm in no position to make a change in regards to this. Best I can do is to trigger a re-verification if we still need to be so specific with this library. |
Alright, since the original problem has been solved, I'm closing the issue |
Steps to reproduce
Click here for reproduction repository
Expected behaviour
Verify function returns either true or false.
Actual behaviour
Node exits with SIGSEGV signal.
Environment
Operating system: Alpine linux (official node docker container)
Node version: 16.X.X
I'm using Typescript v4.3.2
Issue is specific to Node16 & argon2 v0.28.1. Node14 works fine as well as argon2 v0.27.2 (even on Node16).
I'm not sure whether the verify function is the actual or only culprit, but I've seen in my own application that Node definitely crashes while using this function.
The text was updated successfully, but these errors were encountered: