@lov3kaizen/agentsea-redteam 0.5.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.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/dist/attack.types-BK8Qc_Bl.d.ts +82 -0
  3. package/dist/attacks/index.d.ts +186 -0
  4. package/dist/attacks/index.js +1847 -0
  5. package/dist/attacks/index.js.map +1 -0
  6. package/dist/audit/index.d.ts +22 -0
  7. package/dist/audit/index.js +15 -0
  8. package/dist/audit/index.js.map +1 -0
  9. package/dist/audit.types-BiWJxaod.d.ts +215 -0
  10. package/dist/benchmark.types-COcarrIj.d.ts +147 -0
  11. package/dist/benchmarks/index.d.ts +10 -0
  12. package/dist/benchmarks/index.js +11 -0
  13. package/dist/benchmarks/index.js.map +1 -0
  14. package/dist/compliance/index.d.ts +9 -0
  15. package/dist/compliance/index.js +10 -0
  16. package/dist/compliance/index.js.map +1 -0
  17. package/dist/compliance.types-CAnQxiA-.d.ts +187 -0
  18. package/dist/continuous/index.d.ts +21 -0
  19. package/dist/continuous/index.js +18 -0
  20. package/dist/continuous/index.js.map +1 -0
  21. package/dist/continuous.types-Btw2YvvR.d.ts +588 -0
  22. package/dist/core/index.d.ts +363 -0
  23. package/dist/core/index.js +1456 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/detection/index.d.ts +29 -0
  26. package/dist/detection/index.js +309 -0
  27. package/dist/detection/index.js.map +1 -0
  28. package/dist/detection.types-D_TDuLBo.d.ts +170 -0
  29. package/dist/index.d.ts +21 -0
  30. package/dist/index.js +5011 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/integrations/index.d.ts +41 -0
  33. package/dist/integrations/index.js +23 -0
  34. package/dist/integrations/index.js.map +1 -0
  35. package/dist/scanning/index.d.ts +80 -0
  36. package/dist/scanning/index.js +1351 -0
  37. package/dist/scanning/index.js.map +1 -0
  38. package/dist/types/index.d.ts +204 -0
  39. package/dist/types/index.js +3 -0
  40. package/dist/types/index.js.map +1 -0
  41. package/package.json +104 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 lovekaizen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,82 @@
1
+ type AttackCategory = 'jailbreak' | 'prompt_injection' | 'data_exfiltration' | 'manipulation' | 'bypass' | 'social_engineering' | 'privilege_escalation' | 'denial_of_service' | 'information_disclosure' | 'custom';
2
+ type Severity = 'critical' | 'high' | 'medium' | 'low' | 'informational';
3
+ type AttackStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
4
+ type AttackOutcome = 'success' | 'failure' | 'partial' | 'blocked' | 'error';
5
+ interface Attack {
6
+ id: string;
7
+ name: string;
8
+ description: string;
9
+ category: AttackCategory;
10
+ severity: Severity;
11
+ payload: string;
12
+ expectedBehavior?: string;
13
+ tags: string[];
14
+ source?: string;
15
+ mitreMapping?: string;
16
+ metadata?: Record<string, unknown>;
17
+ }
18
+ interface AttackVariant extends Attack {
19
+ originalId: string;
20
+ mutationType: MutationType;
21
+ mutationParams?: Record<string, unknown>;
22
+ }
23
+ type MutationType = 'character_substitution' | 'encoding' | 'unicode_normalization' | 'token_splitting' | 'language_translation' | 'paraphrase' | 'roleplay_wrap' | 'instruction_wrap' | 'context_injection' | 'delimiter_injection' | 'case_variation' | 'whitespace_manipulation' | 'homoglyph_substitution' | 'invisible_characters' | 'custom';
24
+ interface AttackResult {
25
+ attack: Attack;
26
+ outcome: AttackOutcome;
27
+ response: string;
28
+ bypassed: boolean;
29
+ confidence: number;
30
+ detectionIndicators: string[];
31
+ executionTimeMs: number;
32
+ timestamp: number;
33
+ context?: Record<string, unknown>;
34
+ error?: string;
35
+ }
36
+ interface AttackExecutionOptions {
37
+ timeout?: number;
38
+ retries?: number;
39
+ retryDelay?: number;
40
+ continueOnError?: boolean;
41
+ headers?: Record<string, string>;
42
+ temperature?: number;
43
+ modelParams?: Record<string, unknown>;
44
+ }
45
+ interface AttackFilter {
46
+ categories?: AttackCategory[];
47
+ severities?: Severity[];
48
+ tags?: string[];
49
+ query?: string;
50
+ source?: string;
51
+ limit?: number;
52
+ randomSample?: boolean;
53
+ }
54
+ interface AttackLibraryStats {
55
+ totalAttacks: number;
56
+ byCategory: Record<AttackCategory, number>;
57
+ bySeverity: Record<Severity, number>;
58
+ uniqueTags: string[];
59
+ sources: string[];
60
+ }
61
+ interface JailbreakAttack extends Attack {
62
+ category: 'jailbreak';
63
+ technique: JailbreakTechnique;
64
+ knownBypass: boolean;
65
+ affectedModels?: string[];
66
+ }
67
+ type JailbreakTechnique = 'dan' | 'developer_mode' | 'roleplay' | 'hypothetical' | 'reverse_psychology' | 'token_manipulation' | 'multi_turn' | 'context_overflow' | 'instruction_hierarchy' | 'persona' | 'fictional_framing' | 'translation' | 'encoding' | 'custom';
68
+ interface InjectionAttack extends Attack {
69
+ category: 'prompt_injection';
70
+ injectionType: InjectionType;
71
+ targetLocation: 'system' | 'user' | 'assistant' | 'tool';
72
+ }
73
+ type InjectionType = 'direct' | 'indirect' | 'recursive' | 'blind' | 'stored' | 'reflected' | 'dom' | 'custom';
74
+ interface ExfiltrationAttack extends Attack {
75
+ category: 'data_exfiltration';
76
+ targetData: ExfiltrationTarget;
77
+ method: ExfiltrationMethod;
78
+ }
79
+ type ExfiltrationTarget = 'system_prompt' | 'user_data' | 'conversation_history' | 'tool_credentials' | 'internal_state' | 'training_data' | 'configuration' | 'custom';
80
+ type ExfiltrationMethod = 'direct_query' | 'side_channel' | 'inference' | 'error_exploitation' | 'encoding_tricks' | 'context_manipulation' | 'custom';
81
+
82
+ export type { AttackCategory as A, ExfiltrationAttack as E, InjectionAttack as I, JailbreakAttack as J, MutationType as M, Severity as S, AttackStatus as a, AttackOutcome as b, Attack as c, AttackVariant as d, AttackResult as e, AttackExecutionOptions as f, AttackFilter as g, AttackLibraryStats as h, JailbreakTechnique as i, InjectionType as j, ExfiltrationTarget as k, ExfiltrationMethod as l };
@@ -0,0 +1,186 @@
1
+ import { c as Attack, A as AttackCategory, S as Severity, g as AttackFilter, h as AttackLibraryStats, f as AttackExecutionOptions, e as AttackResult, M as MutationType, d as AttackVariant } from '../attack.types-BK8Qc_Bl.js';
2
+ import { EventEmitter } from 'eventemitter3';
3
+ import { TargetConfig } from '../types/index.js';
4
+ import '../continuous.types-Btw2YvvR.js';
5
+ import '../benchmark.types-COcarrIj.js';
6
+ import '../compliance.types-CAnQxiA-.js';
7
+ import '../detection.types-D_TDuLBo.js';
8
+ import '../audit.types-BiWJxaod.js';
9
+
10
+ declare class AttackLibrary {
11
+ private attacks;
12
+ private categoryIndex;
13
+ private severityIndex;
14
+ private tagIndex;
15
+ constructor();
16
+ private initializeIndices;
17
+ private loadBuiltInAttacks;
18
+ register(attack: Attack): void;
19
+ registerMany(attacks: Attack[]): void;
20
+ get(id: string): Attack | undefined;
21
+ getAll(): Attack[];
22
+ getByCategory(category: AttackCategory): Attack[];
23
+ getBySeverity(severity: Severity): Attack[];
24
+ getByTag(tag: string): Attack[];
25
+ filter(filter: AttackFilter): Attack[];
26
+ getStats(): AttackLibraryStats;
27
+ private shuffleArray;
28
+ private loadJailbreakAttacks;
29
+ private loadInjectionAttacks;
30
+ private loadExfiltrationAttacks;
31
+ private loadManipulationAttacks;
32
+ private loadBypassAttacks;
33
+ }
34
+ declare function createAttackLibrary(): AttackLibrary;
35
+ declare const defaultAttackLibrary: AttackLibrary;
36
+
37
+ interface AttackRegistryEvents {
38
+ 'attack:registered': (attack: Attack) => void;
39
+ 'attack:updated': (attack: Attack) => void;
40
+ 'attack:removed': (attackId: string) => void;
41
+ 'category:added': (category: string) => void;
42
+ 'executor:registered': (name: string) => void;
43
+ }
44
+ type AttackExecutor = (attack: Attack, target: TargetConfig, options?: AttackExecutionOptions) => Promise<AttackResult>;
45
+ type AttackValidator = (attack: Attack) => boolean | string;
46
+ interface AttackRegistryConfig {
47
+ includeBuiltIn?: boolean;
48
+ library?: AttackLibrary;
49
+ validators?: AttackValidator[];
50
+ autoDedupe?: boolean;
51
+ }
52
+ declare class AttackRegistry extends EventEmitter<AttackRegistryEvents> {
53
+ private library;
54
+ private executors;
55
+ private customCategories;
56
+ private validators;
57
+ private autoDedupe;
58
+ constructor(config?: AttackRegistryConfig);
59
+ register(attack: Attack): void;
60
+ registerMany(attacks: Attack[]): void;
61
+ unregister(attackId: string): boolean;
62
+ get(attackId: string): Attack | undefined;
63
+ getAll(): Attack[];
64
+ filter(filter: AttackFilter): Attack[];
65
+ getByCategory(category: string): Attack[];
66
+ getBySeverity(severity: Severity): Attack[];
67
+ getByTag(tag: string): Attack[];
68
+ search(query: string): Attack[];
69
+ getStats(): AttackLibraryStats;
70
+ registerExecutor(name: string, executor: AttackExecutor): void;
71
+ getExecutor(name: string): AttackExecutor | undefined;
72
+ getExecutors(): string[];
73
+ execute(attackId: string, target: TargetConfig, executorName?: string, options?: AttackExecutionOptions): Promise<AttackResult>;
74
+ executeMany(attackIds: string[], target: TargetConfig, executorName?: string, options?: AttackExecutionOptions & {
75
+ parallel?: boolean;
76
+ maxParallel?: number;
77
+ }): Promise<AttackResult[]>;
78
+ addValidator(validator: AttackValidator): void;
79
+ validate(attack: Attack): boolean | string;
80
+ importFromJSON(json: string): number;
81
+ exportToJSON(filter?: AttackFilter): string;
82
+ importFromFile(_filePath: string): Promise<number>;
83
+ exportToFile(_filePath: string, _filter?: AttackFilter): Promise<void>;
84
+ private isBuiltInCategory;
85
+ private chunkArray;
86
+ getCustomCategories(): string[];
87
+ getAllCategories(): string[];
88
+ }
89
+ declare function createAttackRegistry(config?: AttackRegistryConfig): AttackRegistry;
90
+ declare const defaultAttackRegistry: AttackRegistry;
91
+
92
+ interface MutationConfig {
93
+ mutations: MutationType[];
94
+ variantsPerMutation?: number;
95
+ combinationDepth?: number;
96
+ preserveOriginal?: boolean;
97
+ customMutators?: Record<string, Mutator>;
98
+ }
99
+ type Mutator = (payload: string, options?: Record<string, unknown>) => string[];
100
+ declare class MutationGenerator {
101
+ private mutators;
102
+ private customMutators;
103
+ constructor();
104
+ private registerBuiltInMutators;
105
+ registerMutator(name: string, mutator: Mutator): void;
106
+ generate(attack: Attack, config: MutationConfig): AttackVariant[];
107
+ generateAll(attack: Attack): AttackVariant[];
108
+ private applyCombinations;
109
+ private createVariant;
110
+ private characterSubstitution;
111
+ private encoding;
112
+ private unicodeNormalization;
113
+ private tokenSplitting;
114
+ private paraphrase;
115
+ private roleplayWrap;
116
+ private instructionWrap;
117
+ private contextInjection;
118
+ private delimiterInjection;
119
+ private caseVariation;
120
+ private whitespaceManipulation;
121
+ private homoglyphSubstitution;
122
+ private invisibleCharacters;
123
+ }
124
+ declare function createMutationGenerator(): MutationGenerator;
125
+
126
+ interface CombinationConfig {
127
+ attacks: Attack[];
128
+ depth?: number;
129
+ maxCombinations?: number;
130
+ strategies?: CombinationStrategy[];
131
+ preserveOrder?: boolean;
132
+ separator?: string;
133
+ }
134
+ type CombinationStrategy = 'sequential' | 'nested' | 'interleaved' | 'prefixed' | 'suffixed' | 'wrapped' | 'merged' | 'custom';
135
+ interface CombinedAttack extends Attack {
136
+ sourceAttacks: string[];
137
+ combinationStrategy: CombinationStrategy;
138
+ }
139
+ declare class CombinationGenerator {
140
+ generate(config: CombinationConfig): CombinedAttack[];
141
+ combineWith(attacks: Attack[], strategy: CombinationStrategy, separator?: string): CombinedAttack | null;
142
+ private generatePairs;
143
+ private generateTriplets;
144
+ private combineAttacks;
145
+ private createNestedPayload;
146
+ private createInterleavedPayload;
147
+ private createWrappedPayload;
148
+ private createMergedPayload;
149
+ private getHighestSeverity;
150
+ generateByCategoryPairs(attacks: Attack[], categoryPairs: [AttackCategory, AttackCategory][]): CombinedAttack[];
151
+ }
152
+ declare function createCombinationGenerator(): CombinationGenerator;
153
+
154
+ interface AdversarialConfig {
155
+ targetCategory?: AttackCategory;
156
+ targetBehavior?: string;
157
+ seedAttacks?: Attack[];
158
+ variants?: number;
159
+ strategies?: AdversarialStrategy[];
160
+ intensity?: 'low' | 'medium' | 'high';
161
+ context?: string;
162
+ }
163
+ type AdversarialStrategy = 'boundary_probing' | 'semantic_perturbation' | 'syntactic_variation' | 'context_manipulation' | 'goal_hijacking' | 'attention_manipulation' | 'gradient_attack' | 'prompt_optimization' | 'few_shot_manipulation';
164
+ interface AdversarialAttack extends Attack {
165
+ strategy: AdversarialStrategy;
166
+ confidence: number;
167
+ targetBehavior?: string;
168
+ generationMetadata?: Record<string, unknown>;
169
+ }
170
+ declare class AdversarialGenerator {
171
+ generate(config: AdversarialConfig): AdversarialAttack[];
172
+ private generateForStrategy;
173
+ private generateBoundaryProbing;
174
+ private generateSemanticPerturbation;
175
+ private generateContextManipulation;
176
+ private generateGoalHijacking;
177
+ private generateAttentionManipulation;
178
+ private generateFewShotManipulation;
179
+ private createAdversarialAttack;
180
+ private perturbPayload;
181
+ private getSeverityForStrategy;
182
+ generateTargeted(targetBehavior: string, count?: number): AdversarialAttack[];
183
+ }
184
+ declare function createAdversarialGenerator(): AdversarialGenerator;
185
+
186
+ export { type AdversarialAttack, type AdversarialConfig, AdversarialGenerator, type AdversarialStrategy, type AttackExecutor, AttackLibrary, AttackRegistry, type AttackRegistryConfig, type AttackRegistryEvents, type AttackValidator, type CombinationConfig, CombinationGenerator, type CombinationStrategy, type CombinedAttack, type MutationConfig, MutationGenerator, type Mutator, createAdversarialGenerator, createAttackLibrary, createAttackRegistry, createCombinationGenerator, createMutationGenerator, defaultAttackLibrary, defaultAttackRegistry };