# Yaa Dependency Analysis

**Analysis Date:** January 2026 **Scope:** Complete Yaa codebase dependency
audit **Methodology:** Package manifest analysis, security audit, catalog
comparison

---

## Table of Contents

1. [Executive Summary](#executive-summary)
2. [Security Vulnerabilities](#security-vulnerabilities)
3. [Dependency Catalog Comparison](#dependency-catalog-comparison)
4. [Node.js Version Alignment](#nodejs-version-alignment)
5. [Outdated Dependencies](#outdated-dependencies)
6. [Duplicate Version Issues](#duplicate-version-issues)
7. [Migration Recommendations](#migration-recommendations)
8. [Update Plan](#update-plan)

---

## Executive Summary

The Yaa codebase contains **1,479 total dependencies** across 95+ packages. The
security audit identified:

| Severity | Count | Status          |
| -------- | ----- | --------------- |
| Critical | 0     | -               |
| High     | 2     | Action Required |
| Moderate | 1     | Action Required |
| Low      | 1     | Monitor         |

**Key Findings:**

- **xlsx** package has HIGH severity vulnerabilities with NO npm fix available
- **esbuild** vulnerability affects ALL packages via vitest → vite chain
- **cookie** vulnerability affects authentication flow in @yaa/web
- Multiple dependencies misaligned with Oshun shared catalog
- Node.js 20 vs Oshun's Node.js 22 requires alignment

**Positive Aspects:**

- React 19 already adopted (ahead of Oshun catalog)
- Core dependencies (pg, ioredis, zod) are up-to-date
- TypeScript 6.0.3 consistently used through the workspace catalog
- No critical severity vulnerabilities

---

## Security Vulnerabilities

### HIGH: xlsx (SheetJS) - CVE-2023-30533 & CVE-2024-22363

**Severity:** HIGH (CVSS 7.8, 7.5) **Affected Package:**
`@yaa/ai-fuel-price-update-generator` **Current Version:** 0.18.5 **Fixed
Version:** 0.20.2+ (NOT available on npm)

**Vulnerabilities:**

1. **CVE-2023-30533** - Prototype Pollution
   - Reading specially crafted files can pollute Object prototype
   - Impact: Arbitrary code execution potential

2. **CVE-2024-22363** - Regular Expression Denial of Service (ReDoS)
   - Malicious input can cause exponential regex backtracking
   - Impact: Service denial via CPU exhaustion

**Location:** `packages/ai/fuel-price-update-generator/package.json:16`

```json
"dependencies": {
  "xlsx": "^0.18.5"
}
```

**Resolution Options:**

1. **Download from CDN** (Recommended)

   ```bash
   # Download patched version from SheetJS CDN
   curl -LO https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz
   # Install from local tarball
   pnpm add ./xlsx-0.20.3.tgz -C packages/ai/fuel-price-update-generator
   ```

2. **Replace with Alternative Library**

   ```typescript
   // Use exceljs instead
   import ExcelJS from 'exceljs';

   const workbook = new ExcelJS.Workbook();
   await workbook.xlsx.readFile('fuel-prices.xlsx');
   ```

3. **Input Validation** (Temporary mitigation)
   ```typescript
   // Only read from trusted, known-good sources
   if (!isTrustedSource(source)) {
     throw new Error('Untrusted XLSX source');
   }
   ```

---

### MODERATE: esbuild - GHSA-67mh-4wv8-2f99

**Severity:** MODERATE (CVSS 5.3) **Affected Packages:** ALL packages via vitest
→ vite → esbuild **Current Version:** 0.21.5 **Fixed Version:** 0.25.0+

**Vulnerability:** CORS Misconfiguration in Development Server

- esbuild sets `Access-Control-Allow-Origin: *` for all requests
- Malicious websites can read source code from dev server
- SSE endpoint exposes file change events

**Attack Scenario:**

1. Developer runs `pnpm test` or `pnpm dev`
2. Attacker serves malicious page at `malicious.example.com`
3. Malicious JS fetches `http://127.0.0.1:5173/main.js`
4. Source code and source maps are exposed

**Dependency Chain (285+ paths):**

```
vitest@2.1.9 → vite@5.4.21 → esbuild@0.21.5
@vitejs/plugin-react → vite@5.4.21 → esbuild@0.21.5
```

**Resolution:**

1. **Update vite** (when available with esbuild ≥0.25.0)

   ```bash
   pnpm update vite -r
   ```

2. **Configure vite CORS** (Temporary)

   ```typescript
   // vite.config.ts
   export default defineConfig({
     server: {
       cors: {
         origin: false, // Disable CORS for local dev
       },
     },
   });
   ```

3. **Development Environment Isolation**
   - Don't run dev server on public networks
   - Use VPN or firewall rules to restrict access

---

### LOW: cookie - CVE-2024-47764

**Severity:** LOW **Affected Package:** `@yaa/web` via @auth/core and next-auth
**Current Version:** 0.6.0 **Fixed Version:** 0.7.0+

**Vulnerability:** Cookie Value Injection

- Cookie name can inject other cookie fields
- Example:
  `serialize("userName=<script>alert('XSS')</script>; Max-Age=2592000; a", value)`
- Results in XSS payload being set as cookie value

**Dependency Chain:**

```
@auth/core@0.34.3 → cookie@0.6.0
next-auth@4.24.13 → @auth/core@0.34.3 → cookie@0.6.0
```

**Resolution:**

1. **Update @auth/core**

   ```bash
   pnpm update @auth/core -C packages/web
   ```

2. **Input Validation** (Temporary)
   ```typescript
   // Validate cookie names before setting
   function validateCookieName(name: string): boolean {
     return /^[a-zA-Z0-9_-]+$/.test(name);
   }
   ```

---

## Dependency Catalog Comparison

### Core Dependencies

| Package              | Oshun Catalog | Yaa Version | Status       | Action         |
| -------------------- | ------------- | ----------- | ------------ | -------------- |
| `@anthropic-ai/sdk`  | ^0.30.0       | ^0.32.0     | Newer        | Update catalog |
| `@aws-sdk/client-s3` | ^3.600.0      | ^3.0.0      | **OUTDATED** | Update Yaa     |
| `@sentry/node`       | ^8.0.0        | ^8.0.0      | Aligned      | -              |
| `bullmq`             | ^5.0.0        | ^5.0.0      | Aligned      | -              |
| `ioredis`            | ^5.3.2        | ^5.4.1      | Newer        | Update catalog |
| `pg`                 | ^8.11.3       | ^8.12.0     | Newer        | Update catalog |
| `zod`                | ^3.23.0       | ^3.23.8     | Newer        | Update catalog |

### Frontend Dependencies

| Package       | Oshun Catalog | Yaa Version | Status         | Action         |
| ------------- | ------------- | ----------- | -------------- | -------------- |
| `react`       | ^18.3.1       | 19.2.3      | **Major**      | Align strategy |
| `react-dom`   | ^18.3.1       | 19.2.3      | **Major**      | Align strategy |
| `next`        | -             | 16.1.2      | Not in catalog | Add to catalog |
| `tailwindcss` | -             | ^4          | Not in catalog | Add to catalog |

### Development Dependencies

| Package       | Oshun Catalog | Yaa Version   | Status    | Action         |
| ------------- | ------------- | ------------- | --------- | -------------- |
| `@types/node` | ^22.0.0       | ^20/^22       | Mixed     | Standardize    |
| `eslint`      | ^9.0.0        | ^9.0.0        | Aligned   | -              |
| `typescript`  | ~5.6.3        | ^5.6.0/^5.0.0 | Mixed     | Standardize    |
| `vitest`      | ^1.6.1        | ^2.0.0/^1.2.1 | **Major** | Align strategy |
| `vite`        | ^5.4.0        | 5.4.21        | Aligned   | -              |

### Backend Dependencies

| Package                  | Oshun Catalog | Yaa Version | Status         | Action         |
| ------------------------ | ------------- | ----------- | -------------- | -------------- |
| `fastify`                | ^4.28.1       | ^4.29.1     | Newer          | Update catalog |
| `hono`                   | ^4.0.0        | -           | Not used       | Optional       |
| `pino`                   | ^9.0.0        | -           | Not used       | Consider       |
| `@elastic/elasticsearch` | -             | ^8.12.0     | Not in catalog | Add to catalog |

---

## Node.js Version Alignment

### Current State

| Project        | Node.js Version                   | Status    |
| -------------- | --------------------------------- | --------- |
| Oshun          | 22.x (implied by @types/node ^22) | Target    |
| Yaa            | 20.x (engines: >=20.0.0)          | Current   |
| Actual Runtime | 20.19.6                           | Installed |

### Node.js 22 Features Used by Oshun

- Native `fetch` improvements
- Better ESM support
- V8 engine updates
- Enhanced `AbortSignal.any()`
- Native WebSocket in Node.js

### Migration Requirements

1. **Update engines field in all package.json files**

   ```json
   "engines": {
     "node": ">=22.0.0"
   }
   ```

2. **Update @types/node consistently**

   ```bash
   pnpm update @types/node@^22.0.0 -r
   ```

3. **Test compatibility**
   - Verify all native addons compile on Node.js 22
   - Check for deprecated API usage
   - Run full test suite

---

## Outdated Dependencies

### Critical Updates Required

| Package              | Current | Latest       | Risk   | Priority |
| -------------------- | ------- | ------------ | ------ | -------- |
| `xlsx`               | 0.18.5  | 0.20.3 (CDN) | HIGH   | P0       |
| `@aws-sdk/client-s3` | ^3.0.0  | ^3.600.0+    | MEDIUM | P1       |
| `@types/uuid`        | ^9.0.8  | ^10.0.0      | LOW    | P2       |
| `uuid`               | ^9.0.1  | ^10.0.0      | LOW    | P2       |

### Version Inconsistencies Across Packages

**@types/node:**

- `^22.0.0` - 60+ packages
- `^20.0.0` - 5 packages
- `^20.10.0` - 2 packages
- `^20.11.5` - 1 package
- `^20` - 1 package (web)

**typescript:**

- `^5.6.0` - 50+ packages
- `^5.3.0` - 5 packages
- `^5.3.3` - 2 packages
- `^5.0.0` - 1 package
- `^5` - 1 package (web)

**vitest:**

- `^2.0.0` - 80+ packages
- `^1.2.1` - 3 packages
- `^1.6.1` - 3 packages (social)

**pg:**

- `^8.12.0` - 30+ packages
- `^8.11.0` - 2 packages
- `^8.0.0` - 1 package

---

## Duplicate Version Issues

### Multiple React Versions Risk

```
react@19.2.3 (packages/web)
react@18.3.1 (may exist in node_modules)
```

**Resolution:** Use pnpm overrides to enforce single version:

```yaml
# pnpm-workspace.yaml
pnpm:
  overrides:
    react: 19.2.3
    react-dom: 19.2.3
```

### TypeScript Version Spread

Having 5+ different TypeScript patch versions can cause:

- Inconsistent type checking behavior
- Build cache invalidation
- IDE confusion

**Resolution:** Standardize on single version:

```json
// All package.json files
"devDependencies": {
  "typescript": "catalog:"
}
```

---

## Migration Recommendations

### Phase 1: Security Fixes (Immediate)

1. **Replace xlsx with exceljs**

   ```bash
   pnpm remove xlsx -C packages/ai/fuel-price-update-generator
   pnpm add exceljs -C packages/ai/fuel-price-update-generator
   ```

   Update code:

   ```typescript
   // Before
   import * as XLSX from 'xlsx';
   const workbook = XLSX.readFile(path);
   const sheet = workbook.Sheets[workbook.SheetNames[0]];
   const data = XLSX.utils.sheet_to_json(sheet);

   // After
   import ExcelJS from 'exceljs';
   const workbook = new ExcelJS.Workbook();
   await workbook.xlsx.readFile(path);
   const sheet = workbook.worksheets[0];
   const data = sheet
     .getSheetValues()
     .filter((row) => row)
     .map((row) => (Array.isArray(row) ? row.slice(1) : []));
   ```

2. **Update @auth/core**
   ```bash
   pnpm update @auth/core next-auth -C packages/web
   ```

### Phase 2: Catalog Alignment (This Sprint)

1. **Add Yaa-specific dependencies to Oshun catalog**

   ```yaml
   # pnpm-workspace.yaml additions
   catalog:
     '@elastic/elasticsearch': ^8.15.0
     'next': ^16.1.2
     'next-auth': ^5.0.0
     'tailwindcss': ^4.0.0
     'rss-parser': ^3.13.0
     'cheerio': ^1.1.2
     'firebase': ^12.8.0
     'firebase-admin': ^13.6.0
   ```

2. **Update Yaa packages to use catalog references**
   ```json
   "dependencies": {
     "pg": "catalog:",
     "ioredis": "catalog:",
     "zod": "catalog:"
   }
   ```

### Phase 3: Version Standardization (This Month)

1. **Standardize @types/node**

   ```bash
   pnpm update @types/node@^22.0.0 -r --filter "./yaa/**"
   ```

2. **Standardize typescript**

   ```bash
   pnpm update typescript@~5.6.3 -r --filter "./yaa/**"
   ```

3. **Standardize vitest**
   ```bash
   pnpm update vitest@^2.1.0 -r --filter "./yaa/**"
   ```

### Phase 4: Node.js Upgrade (This Quarter)

1. **Update .nvmrc**

   ```bash
   echo "22" > .nvmrc
   ```

2. **Update CI/CD pipelines**

   ```yaml
   # GitHub Actions
   - uses: actions/setup-node@v4
     with:
       node-version: '22'
   ```

3. **Update Docker base images**

   ```dockerfile
   FROM node:22-alpine
   ```

4. **Update package.json engines**
   ```bash
   # Script to update all packages
   find packages -name "package.json" -exec sed -i 's/"node": ">=20.0.0"/"node": ">=22.0.0"/g' {} \;
   ```

---

## Update Plan

### Immediate Actions (P0)

| Task    | Package     | Action                | Risk   |
| ------- | ----------- | --------------------- | ------ |
| SEC-001 | xlsx        | Replace with exceljs  | HIGH   |
| SEC-002 | @auth/core  | Update to latest      | MEDIUM |
| SEC-003 | vite.config | Add CORS restrictions | LOW    |

### Short-term Actions (P1 - This Sprint)

| Task    | Scope        | Action                                |
| ------- | ------------ | ------------------------------------- |
| DEP-001 | All packages | Standardize @types/node to ^22.0.0    |
| DEP-002 | All packages | Standardize typescript to ~5.6.3      |
| DEP-003 | All packages | Standardize vitest to ^2.1.0          |
| DEP-004 | @yaa/api     | Update @aws-sdk/client-s3 to ^3.600.0 |

### Medium-term Actions (P2 - This Month)

| Task     | Scope               | Action                          |
| -------- | ------------------- | ------------------------------- |
| CAT-001  | pnpm-workspace.yaml | Add Yaa dependencies to catalog |
| CAT-002  | All Yaa packages    | Convert to catalog: references  |
| NODE-001 | All packages        | Update engines to >=22.0.0      |
| NODE-002 | CI/CD               | Update to Node.js 22            |

### Long-term Actions (P3 - This Quarter)

| Task      | Scope         | Action                        |
| --------- | ------------- | ----------------------------- |
| REACT-001 | Oshun libs    | Evaluate React 19 adoption    |
| NEXT-001  | Oshun catalog | Add Next.js to shared catalog |
| TEST-001  | All packages  | Align on vitest 2.x           |

---

## Appendix: Full Dependency List

### Production Dependencies (Direct)

```
@anthropic-ai/sdk: ^0.32.0
@auth/core: 0.34.3
@aws-sdk/client-s3: ^3.0.0
@elastic/elasticsearch: ^8.12.0
@fastify/cors: ^9.0.1
@fastify/swagger: ^8.15.0
@fastify/swagger-ui: ^3.1.0
@radix-ui/react-dialog: ^1.0.0
@radix-ui/react-dropdown-menu: ^2.0.0
@radix-ui/react-icons: ^1.0.0
@radix-ui/react-slot: ^1.0.0
@radix-ui/react-tooltip: ^1.0.0
@reduxjs/toolkit: ^2.0.0
@sentry/node: ^8.0.0
bcryptjs: ^2.4.3
bullmq: ^5.0.0
cheerio: ^1.0.0-rc.12 / ^1.1.2
class-variance-authority: ^0.7.0
clsx: ^2.1.0
date-fns: ^3.0.0 / ^3.3.1
date-fns-tz: ^2.0.0
domhandler: ^5.0.3
fastify: ^4.29.1
firebase: ^12.8.0
firebase-admin: ^13.6.0
franc: ^6.2.0
ioredis: ^5.4.1
next: 16.1.2
next-auth: ^4.24.13
next-themes: ^0.4.0
nodemailer: ^7.0.7
pg: ^8.0.0 - ^8.12.0
react: 19.2.3
react-dom: 19.2.3
react-redux: ^9.0.0
remark: ^15.0.0
remark-gfm: ^4.0.0
remark-html: ^16.0.0
rrule: ^2.8.1
rss-parser: ^3.13.0
sharp: ^0.33.0
simple-statistics: ^7.8.3
tailwind-merge: ^2.5.0
uuid: ^9.0.1 / ^10.0.0
xlsx: ^0.18.5 (VULNERABLE)
zod: ^3.23.8
```

### Development Dependencies (Direct)

```
@resvg/resvg-js: ^2.6.0
@tailwindcss/postcss: ^4
@tailwindcss/typography: ^0.5.15
@testing-library/jest-dom: ^6.0.0
@testing-library/react: ^16.0.0
@types/bcryptjs: ^2.4.6
@types/node: ^20 - ^22.0.0
@types/nodemailer: ^6.4.17
@types/pg: ^8.10.0 - ^8.16.0
@types/react: ^19
@types/react-dom: ^19
@types/uuid: ^9.0.8 / ^10.0.0
@typescript-eslint/eslint-plugin: ^8.0.0
@typescript-eslint/parser: ^8.0.0
@vitejs/plugin-react: ^4.0.0
eslint: ^9 / ^9.0.0
eslint-config-next: 16.1.2
jsdom: ^25.0.0
tailwindcss: ^4
typescript: ^6.0.3
vitest: ^1.2.1 / ^1.6.1 / ^2.0.0
```

---

_Analysis Date: January 2026_

_Part of the Veritas domain integration documentation_
