
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
ssr-only-secrets
Advanced tools
This package provides a way to pass secrets from Server Components into the SSR-run of Client Components, without them being accessible in the browser.
This package provides a way to pass secrets from Server Components into the SSR-run of Client Components without them being accessible in the browser.
This technique was inspired by this comment by @Stevemoretz.
Install the package
npm i ssr-only-secrets
Generate a jwk-formatted AES-CBC key, e.g. by running
crypto.subtle
.generateKey(
{
name: "AES-CBC",
length: 256,
},
true,
["encrypt", "decrypt"]
)
.then((key) => crypto.subtle.exportKey("jwk", key))
.then(JSON.stringify)
.then(console.log);
and store the result in an environment variable, e.g. SECRET_KEY_VAR
, e.g. by writing it into your .env.local
.
SECRET_KEY_VAR={"alg":"A256CBC","ext":true,"k":"...","key_ops":["encrypt","decrypt"],"kty":"oct"}
Now, you can pass "cloaked secrets" from your Server Components into the SSR-run of your Client Components, without them being accessible in your Client Components in the browser.
In a Server Component:
import { cloakSSROnlySecret } from "ssr-only-secrets";
const MyServerComponent = () => {
const secretValue = "my secret value"
return <ClientComponent ssrOnlySecret={cloakSSROnlySecret(secretValue, "SECRET_KEY_VAR")} />
}
And in a Client Component
import { useSSROnlySecret } from "ssr-only-secrets";
const ClientComponent = ({ssrOnlySecret}, "SECRET_KEY_VAR") => {
const value = useSSROnlySecret(ssrOnlySecret);
console.log(value); // during SSR, this logs "my secret value", but in the browser, it logs "undefined"
}
Alternatively, you can decrypt the secret in your code by calling readSSROnlySecret
, e.g. in an Apollo Link:
const value = await readSSROnlySecret(ssrOnlySecret)
Function | Description |
---|---|
cloakSSROnlySecret(secret, encryptionEnvVarName) | Encrypts a secret so that it can be passed from Server Components into the SSR-run of Client Components without them being accessible in the browser. Use Only available in Server Components. |
readSSROnlySecret(cloakedSecret, encryptionEnvVarName) | Decrypts a secret that was created in a Server Component using Calling this in a Browser environment will always return Only available in Client Components. |
useSSROnlySecret(cloakedSecret, encryptionEnvVarName) | Decrypts a secret that was created in a Server Component using Calling this in a Browser environment will always return Only available in Client Components. |
FAQs
This package provides a way to pass secrets from Server Components into the SSR-run of Client Components, without them being accessible in the browser.
The npm package ssr-only-secrets receives a total of 3,983 weekly downloads. As such, ssr-only-secrets popularity was classified as popular.
We found that ssr-only-secrets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.