You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/linux-hardening/privilege-escalation/README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -985,6 +985,48 @@ BASH_ENV=/dev/shm/shell.sh sudo /usr/bin/systeminfo # or any permitted script/
985
985
- Avoid shell wrappers for sudo-allowed commands; use minimal binaries.
986
986
- Consider sudo I/O logging and alerting when preserved env vars are used.
987
987
988
+
### Terraform via sudo with preserved HOME (!env_reset)
989
+
990
+
If sudo leaves the environment intact (`!env_reset`) while allowing `terraform apply`, `$HOME` stays as the calling user. Terraform therefore loads **$HOME/.terraformrc** as root and honors `provider_installation.dev_overrides`.
991
+
992
+
- Point the required provider at a writable directory and drop a malicious plugin named after the provider (e.g., `terraform-provider-examples`):
Terraform will fail the Go plugin handshake but executes the payload as root before dying, leaving a SUID shell behind.
1016
+
1017
+
### TF_VAR overrides + symlink validation bypass
1018
+
1019
+
Terraform variables can be provided via `TF_VAR_<name>` environment variables, which survive when sudo preserves the environment. Weak validations such as `strcontains(var.source_path, "/root/examples/") &&!strcontains(var.source_path, "..")` can be bypassed with symlinks:
Terraform resolves the symlink and copies the real `/root/root.txt` into an attacker-readable destination. The same approach can be used to **write** into privileged paths by pre-creating destination symlinks (e.g., pointing the provider’s destination path inside `/etc/cron.d/`).
If `sudo -l` shows `env_keep+=PATH` or a `secure_path` containing attacker-writable entries (e.g., `/home/<user>/bin`), any relative command inside the sudo-allowed target can be shadowed.
Copy file name to clipboardExpand all lines: src/network-services-pentesting/pentesting-web/nextjs.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -415,6 +415,20 @@ export default function DownloadPage() {
415
415
416
416
</details>
417
417
418
+
### Recon: static export route discovery via _buildManifest
419
+
420
+
When `nextExport`/`autoExport` are true (static export), Next.js exposes the `buildId` in the HTML and serves a build manifest at `/_next/static/<buildId>/_buildManifest.js`. The `sortedPages` array and route→chunk mapping there enumerate every prerendered page without brute force.
421
+
422
+
- Grab the buildId from the root response (often printed at the bottom) or from `<script>` tags loading `/_next/static/<buildId>/...`.
If authorization is enforced in middleware, affected Next.js releases (<12.3.5 / 13.5.9 / 14.2.25 / 15.2.3) can be bypassed by injecting the `x-middleware-subrequest` header. The framework will skip middleware recursion and return the protected page.
901
+
902
+
- Baseline behavior is typically a 307 redirect to a login route like `/api/auth/signin`.
903
+
- Send a long `x-middleware-subrequest` value (repeat `middleware` to hit `MAX_RECURSION_DEPTH`) to flip the response to 200:
- Because authenticated pages pull many subresources, add the header to every request (e.g., Burp Match/Replace with an empty match string) to keep assets from redirecting.
911
+
884
912
### `next.config.js`
885
913
886
914
**Location:** Root of the project.
@@ -1203,6 +1231,15 @@ module.exports = {
1203
1231
1204
1232
**Note:** To restrict variables to server-side only, omit them from the `env` object or prefix them with `NEXT_PUBLIC_` for client exposure.
1205
1233
1234
+
### Useful server artifacts to target via LFI/download endpoints
1235
+
1236
+
If you find a path traversal or download API in a Next.js app, target compiled artifacts that leak server-side secrets and auth logic:
1237
+
1238
+
-`.env` / `.env.local` for session secrets and provider credentials.
1239
+
-`.next/routes-manifest.json` and `.next/build-manifest.json` for a complete route list.
1240
+
-`.next/server/pages/api/auth/[...nextauth].js` to recover the compiled NextAuth configuration (often contains fallback passwords when `process.env` values are unset).
1241
+
-`next.config.js` / `next.config.mjs` to review rewrites, redirects and middleware routing.
-[CVE-2025-55182 React Server Components Remote Code Execution Exploit Tool](https://github.com/Spritualkb/CVE-2025-55182-exp)
1403
1440
-[CVE-2025-55182 & CVE-2025-66478 React2Shell – All You Need to Know](https://jfrog.com/blog/2025-55182-and-2025-66478-react2shell-all-you-need-to-know/)
0 commit comments