trace-sec 2.1.14 → 2.1.15

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/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "trace-sec",
3
- "version": "2.1.14",
3
+ "version": "2.1.15",
4
4
  "description": "Threat Reconnaissance & Attack-path Correlation Engine — Security Verification Layer for Coding Agents with Fine-Tuned SecureBERT 2.0 & Laya AI",
5
5
  "type": "module",
6
6
  "main": "bin/trace.js",
7
- "scripts": {
8
- "postinstall": "node bin/postinstall.js"
9
- },
10
7
  "bin": {
11
8
  "trace": "bin/trace.js",
12
9
  "trace-sec": "bin/trace.js",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "trace-sec"
7
- version = "2.1.14"
7
+ version = "2.1.15"
8
8
  description = "Threat Reconnaissance & Attack-path Correlation Engine"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -3,6 +3,6 @@
3
3
  Local-first application security analysis and runtime validation engine.
4
4
  """
5
5
 
6
- __version__ = "2.1.14"
6
+ __version__ = "2.1.15"
7
7
  __app_name__ = "TRACE"
8
8
  __description__ = "Threat Reconnaissance & Attack-path Correlation Engine"
@@ -23,6 +23,140 @@ def get_detailed_remediation_and_root_cause(
23
23
  ev_text = " ".join(static_evidence or []).lower()
24
24
  cat_upper = category.upper()
25
25
 
26
+ # Confidential Startup Workspace IP Exfiltration (BOLA / Exposure)
27
+ if any(k in ep_lower for k in ("/dashboard/workspace", "/dashboard/business", "/dashboard/branding", "/dashboard/product", "/dashboard/engineering", "/dashboard/project-management")):
28
+ root_cause = (
29
+ f"Endpoint `{endpoint}` directly reads proprietary startup intellectual property (business models, architecture plans, branding assets) "
30
+ f"using an unvalidated workspace ID parameter (`req.params.id`). The handler lacks session authentication and tenant "
31
+ f"ownership checks, allowing any external caller to exfiltrate confidential startup intellectual property simply by enumerating IDs."
32
+ )
33
+ remediation = (
34
+ "1. Mount `verifyToken` middleware on the dashboard router: `router.use(verifyToken)` in `dashboardRoutes.js`.\n"
35
+ "2. In the route handler, fetch the workspace and verify tenant ownership: `if (workspace.userId !== req.user.id) return res.status(403).json({ error: 'Unauthorized access to workspace' })`.\n"
36
+ "3. Reject unauthenticated requests with HTTP 401 and unauthorized workspace queries with HTTP 403 Forbidden."
37
+ )
38
+ short_action = "Assert req.user ownership of workspaceId before disclosing startup IP."
39
+ return root_cause, remediation, short_action
40
+
41
+ # AI Market Analysis & LLM Resource Exhaustion
42
+ if any(k in ep_lower for k in ("/discovery/analyze", "/discovery/competitive-advantage")):
43
+ root_cause = (
44
+ f"Endpoint `{endpoint}` dispatches directly into the backend AI discovery pipeline and LLM provider without "
45
+ f"caller authentication or request throttling. Malicious or automated callers can spam this endpoint to exhaust "
46
+ f"backend AI API token budgets (denial-of-wallet) or inject adversarial prompt payloads."
47
+ )
48
+ remediation = (
49
+ "1. Guard `{endpoint}` with `verifyToken` authentication middleware.\n"
50
+ "2. Apply rate-limiting middleware (`express-rate-limit`) to restrict users to a reasonable quota (e.g. 10 requests / hour).\n"
51
+ "3. Sanitize incoming prompt inputs (`startupIdea`, `targetAudience`) to mitigate prompt injection attacks."
52
+ )
53
+ short_action = "Apply verifyToken and express-rate-limit to throttle AI market analysis."
54
+ return root_cause, remediation, short_action
55
+
56
+ # Insecure Session State Manipulation / Poisoning
57
+ if any(k in ep_lower for k in ("/discovery/identity", "/discovery/mvp", "/discovery/product-config", "/discovery/tech-preferences", "/discovery/business-model", "/discovery/additional-info")):
58
+ step_name = endpoint.split("/")[-1]
59
+ root_cause = (
60
+ f"The `{step_name}` wizard step on `{endpoint}` takes an unauthenticated client-supplied `sessionId` and updates "
61
+ f"in-flight discovery state via `store.updateSession()`. Because sessions are not bound to verified user credentials, "
62
+ f"an attacker can guess or spoof a `sessionId` to overwrite, poison, or corrupt another founder's startup definitions."
63
+ )
64
+ remediation = (
65
+ "1. When initializing discovery sessions, bind `session.userId = req.user.id` using verified token claims.\n"
66
+ "2. In `{endpoint}`, assert that `session.userId === req.user.id` before calling `store.updateSession()`.\n"
67
+ "3. Use cryptographically unguessable UUIDs for session identifiers and reject unauthorized updates with HTTP 403 Forbidden."
68
+ )
69
+ short_action = "Bind sessionId to req.user.id to prevent cross-session state poisoning."
70
+ return root_cause, remediation, short_action
71
+
72
+ # Unauthorized Workspace Generation
73
+ if "/discovery/generate-workspace" in ep_lower:
74
+ root_cause = (
75
+ f"Endpoint `{endpoint}` aggregates onboarding data and instantiates a permanent startup workspace entity based solely "
76
+ f"on a raw `sessionId` in `req.body`. Anyone who obtains a session ID can trigger final workspace creation without "
77
+ f"caller verification, enabling session hijacking and unauthorized workspace instantiation."
78
+ )
79
+ remediation = (
80
+ "1. Protect `/generate-workspace` with `verifyToken` middleware.\n"
81
+ "2. Verify that `session.userId === req.user.id` before executing `store.generateWorkspace(sessionId)`.\n"
82
+ "3. Invalidate or mark the session as completed to prevent double-generation race conditions."
83
+ )
84
+ short_action = "Authenticate caller and verify session ownership before generating workspace."
85
+ return root_cause, remediation, short_action
86
+
87
+ # Autonomous Agent Pipeline Dispatch
88
+ if "/orchestrator/run" in ep_lower:
89
+ root_cause = (
90
+ f"Endpoint `{endpoint}` triggers the autonomous orchestrator agent pipeline (`orchestratorBridge.runOrchestration`) "
91
+ f"with an unvalidated user prompt. Exposing agent execution without authentication allows attackers to dispatch "
92
+ f"arbitrary commands against any workspace, poison agent context, and consume server compute."
93
+ )
94
+ remediation = (
95
+ "1. Guard `/api/orchestrator/run` with `verifyToken` middleware.\n"
96
+ "2. Verify that `req.user` is an authorized collaborator on the target `workspaceId`.\n"
97
+ "3. Sanitize the input `query` against prompt injection and enforce strict timeout and token budget constraints."
98
+ )
99
+ short_action = "Require verifyToken and sanitize query before dispatching autonomous agent."
100
+ return root_cause, remediation, short_action
101
+
102
+ # Sprint Plan Generation / Overwrite
103
+ if "/orchestrator/generate-plan" in ep_lower:
104
+ root_cause = (
105
+ f"Endpoint `{endpoint}` triggers automated generation of weekly/monthly execution plans for a given `workspaceId`. "
106
+ f"Without authentication or authorization checks, an unauthorized actor can overwrite existing sprint roadmaps, "
107
+ f"milestones, and active deliverables for any startup."
108
+ )
109
+ remediation = (
110
+ "1. Mount `verifyToken` middleware on `/api/orchestrator`.\n"
111
+ "2. Verify that `req.user` has workspace admin/editor permissions before invoking `orchestratorService.generatePlan()`.\n"
112
+ "3. Preserve historical plan versions instead of destructive in-place overwrites."
113
+ )
114
+ short_action = "Verify workspace management permissions before regenerating project plans."
115
+ return root_cause, remediation, short_action
116
+
117
+ # Deliverable & Task Status Tampering
118
+ if "/orchestrator/deliverable" in ep_lower:
119
+ root_cause = (
120
+ f"Endpoint `{endpoint}` permits status modifications (`pending`, `completed`, `rolled-over`) and arbitrary field updates to project deliverables "
121
+ f"using path parameters `planId` and `deliverableId`. The route lacks caller verification, enabling malicious actors to falsify project milestones and corrupt sprint metrics."
122
+ )
123
+ remediation = (
124
+ "1. Require session authentication via `verifyToken`.\n"
125
+ "2. Verify that the plan identified by `req.params.planId` belongs to a workspace where `req.user` is an active member.\n"
126
+ "3. Validate status transitions against allowed state machines and reject unauthorized updates with HTTP 403 Forbidden."
127
+ )
128
+ short_action = "Enforce workspace membership check before patching deliverable status."
129
+ return root_cause, remediation, short_action
130
+
131
+ # Schedule Roll-Forward Manipulation
132
+ if "/orchestrator/rollforward" in ep_lower:
133
+ root_cause = (
134
+ f"Endpoint `{endpoint}` reschedules uncompleted deliverables from past dates to today. Because it lacks access control, "
135
+ f"external actors can trigger roll-forward operations on arbitrary plans, disrupting task deadlines and sprint audit trails."
136
+ )
137
+ remediation = (
138
+ "1. Protect `{endpoint}` with `verifyToken`.\n"
139
+ "2. Validate that `req.user` has editor or admin rights on the workspace owning `planId`.\n"
140
+ "3. Record audit logs for roll-forward triggers with timestamps and caller ID."
141
+ )
142
+ short_action = "Restrict plan roll-forward operations to authenticated team members."
143
+ return root_cause, remediation, short_action
144
+
145
+ # Project Roadmaps & Progress Disclosure
146
+ if any(k in ep_lower for k in ("/orchestrator/plans/", "/orchestrator/active-plan/", "/orchestrator/dashboard/")):
147
+ root_cause = (
148
+ f"Endpoint `{endpoint}` returns sprint plans, active tasks, upcoming deadlines, and progress metrics for the specified "
149
+ f"`workspaceId`. Without authentication or tenant checks, external actors can inspect internal development roadmaps, "
150
+ f"proprietary feature deadlines, and team deliverables."
151
+ )
152
+ remediation = (
153
+ "1. Mount `verifyToken` middleware on the orchestrator router.\n"
154
+ "2. Verify that `req.user` is a verified member of `workspaceId` before calling `planStore` or `orchestratorService`.\n"
155
+ "3. Return HTTP 403 Forbidden if the caller is not affiliated with the workspace."
156
+ )
157
+ short_action = "Verify workspace membership before disclosing plan roadmaps and tasks."
158
+ return root_cause, remediation, short_action
159
+
26
160
  # 1. Caller-Controlled Ownership Bypass via Optional Parameter
27
161
  if "caller-controlled" in t_lower or "assert_coach_owns_athlete" in ev_text or ("coach_id" in ev_text and "bypass" in t_lower):
28
162
  root_cause = (
@@ -129,6 +263,21 @@ def get_detailed_remediation_and_root_cause(
129
263
 
130
264
  # 7. Insecure CORS Configuration
131
265
  if cat_upper == "CORS" or "cors" in t_lower:
266
+ if "localhost" in ev_text or "3000" in ev_text or "backend/server.js" in filepath:
267
+ root_cause = (
268
+ f"CORS configuration on `{endpoint}` uses hardcoded `origin: 'http://localhost:3000'`. "
269
+ f"Static development origin definitions in server code leave production deployments vulnerable "
270
+ f"to misconfiguration or unintended cross-origin access from local debugging ports."
271
+ )
272
+ remediation = (
273
+ "1. Load allowed origins dynamically from environment variables: "
274
+ "`const allowedOrigins = (process.env.ALLOWED_ORIGINS || 'http://localhost:3000').split(','); app.use(cors({ origin: allowedOrigins }));`.\n"
275
+ "2. Ensure credentials (`credentials: true`) are never combined with wildcard origins.\n"
276
+ "3. Reject cross-origin requests from unlisted origin headers."
277
+ )
278
+ short_action = "Configure CORS origins dynamically via environment variable rather than hardcoding localhost."
279
+ return root_cause, remediation, short_action
280
+
132
281
  root_cause = (
133
282
  f"`CORSMiddleware` on `{endpoint}` is configured with `allow_origins=['*']` combined with "
134
283
  f"`allow_credentials=True`. This permits arbitrary third-party websites to execute credentialed "
@@ -158,7 +158,11 @@ class ExpressFrameworkAdapter(FrameworkAdapter):
158
158
  content_lower = content.lower()
159
159
  has_db_sink = any(
160
160
  term in content_lower
161
- for term in ("mongoose", "prisma", "sequelize", "knex", "pool.query", "db.query", "db.collection")
161
+ for term in (
162
+ "mongoose", "prisma", "sequelize", "knex", "pool.query", "db.query", "db.collection",
163
+ "supabase", "store.", "planstore", "discoverystore", "findone", "find(", "findby",
164
+ "getworkspace", "getplan", "getsession", "model."
165
+ )
162
166
  )
163
167
  has_ext_sink = any(
164
168
  term in content_lower
@@ -267,6 +267,69 @@ class HypothesisEngine:
267
267
  )
268
268
  )
269
269
  hypo_idx += 1
270
+ elif any(term in ep.path.lower() for term in ("analyze", "competitive-advantage", "generate-workspace", "generate-plan", "orchestrator/run")):
271
+ # Case: Unauthenticated AI Agent / LLM Inference Pipeline
272
+ hypotheses.append(
273
+ SecurityHypothesis(
274
+ id=f"HYP-AUTH-{hypo_idx:03d}",
275
+ category=VulnerabilityCategory.AUTHENTICATION,
276
+ endpoint_id=ep.id,
277
+ endpoint_display=ep_disp,
278
+ title=f"Unauthenticated AI Agent Pipeline / Token Depletion on {ep_disp}",
279
+ description="Endpoint invokes expensive backend AI agent or LLM pipelines without authentication or rate-limiting, exposing the application to token exhaustion and prompt injection.",
280
+ recommended_test_pack="authentication",
281
+ confidence_prior=0.85,
282
+ static_evidence=[
283
+ f"AI Agent / LLM reasoning endpoint: {ep.method} {ep.path}",
284
+ "No authentication or caller identity verification detected",
285
+ "Risk: Denial-of-wallet, unbounded LLM token consumption, prompt injection",
286
+ ],
287
+ severity=Severity.HIGH,
288
+ )
289
+ )
290
+ hypo_idx += 1
291
+ elif any(term in ep.path.lower() for term in ("identity", "mvp", "product-config", "tech-preferences", "business-model", "additional-info")):
292
+ # Case: Multi-step wizard session state mutation
293
+ hypotheses.append(
294
+ SecurityHypothesis(
295
+ id=f"HYP-AUTH-{hypo_idx:03d}",
296
+ category=VulnerabilityCategory.AUTHENTICATION,
297
+ endpoint_id=ep.id,
298
+ endpoint_display=ep_disp,
299
+ title=f"Insecure Discovery Session State Mutation on {ep_disp}",
300
+ description="Endpoint updates onboarding discovery session data using client-supplied sessionId without session tenant verification, enabling session hijacking and state poisoning.",
301
+ recommended_test_pack="authentication",
302
+ confidence_prior=0.80,
303
+ static_evidence=[
304
+ f"Discovery session state modification: {ep.method} {ep.path}",
305
+ "Client-controlled sessionId parameter without verified caller ownership",
306
+ "Risk: Cross-session data corruption and poisoning of startup configuration",
307
+ ],
308
+ severity=Severity.HIGH,
309
+ )
310
+ )
311
+ hypo_idx += 1
312
+ elif any(term in ep.path.lower() for term in ("deliverable", "rollforward")):
313
+ # Case: Unauthorized task status / sprint roadmap mutation
314
+ hypotheses.append(
315
+ SecurityHypothesis(
316
+ id=f"HYP-AUTH-{hypo_idx:03d}",
317
+ category=VulnerabilityCategory.AUTHENTICATION,
318
+ endpoint_id=ep.id,
319
+ endpoint_display=ep_disp,
320
+ title=f"Unauthorized Sprint Deliverable & Schedule Manipulation on {ep_disp}",
321
+ description="Endpoint updates deliverable statuses or rolls forward sprint deadlines without verifying workspace membership or caller permissions.",
322
+ recommended_test_pack="authentication",
323
+ confidence_prior=0.80,
324
+ static_evidence=[
325
+ f"Deliverable/schedule mutation: {ep.method} {ep.path}",
326
+ "Missing workspace collaborator or editor role check",
327
+ "Risk: Tampering with project sprint audit trails and deliverable completion status",
328
+ ],
329
+ severity=Severity.HIGH,
330
+ )
331
+ )
332
+ hypo_idx += 1
270
333
  elif any(term in ep.path.lower() for term in ("scatt-analysis", "inference", "predict", "telemetry/analyze")) and not ep.database_access:
271
334
  # Case: Stateless ML/inference compute endpoint (low impact)
272
335
  hypotheses.append(
@@ -316,7 +379,7 @@ class HypothesisEngine:
316
379
  category=VulnerabilityCategory.AUTHENTICATION,
317
380
  endpoint_id=ep.id,
318
381
  endpoint_display=ep_disp,
319
- title=f"Unauthenticated sensitive endpoint {ep_disp}",
382
+ title=f"Unauthenticated Sensitive Route Exposure on {ep_disp}",
320
383
  description="Sensitive or state-modifying endpoint does not declare authentication requirement.",
321
384
  recommended_test_pack="authentication",
322
385
  confidence_prior=0.80,