Skip to content

feat(chat): RAG-powered /chat assistant POC - #590

Open
phrogwrld wants to merge 10 commits into
mainfrom
feat/rag-chat-poc
Open

feat(chat): RAG-powered /chat assistant POC#590
phrogwrld wants to merge 10 commits into
mainfrom
feat/rag-chat-poc

Conversation

@phrogwrld

Copy link
Copy Markdown
Contributor

No description provided.

@amazon-inspector-n-virginia

Copy link
Copy Markdown

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontend-alpha Ready Ready Preview, Comment May 22, 2026 7:25pm
frontend-alpha-poc-bank-holiday Ready Ready Preview, Comment May 22, 2026 7:25pm

Comment thread scripts/rag-ingest.ts
}

main().catch((err) => {
console.error(err);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description: Log Injection occurs when untrusted user input is directly written to log files without proper sanitization. This can allow attackers to manipulate log entries, potentially leading to security issues like log forging or cross-site scripting. To prevent this, always sanitize user input before logging by removing or encoding newline characters, using string encoding functions, and leveraging built-in sanitization features of logging libraries when available. Learn more - https://cwe.mitre.org/data/definitions/117.html

Severity: High

Comment thread scripts/rag-ingest.ts
parts.length === 1
? [
path.join(CONTENT_DIR, parts[0], "index.md"),
path.join(CONTENT_DIR, `${parts[0]}.md`),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description: Path traversal vulnerability detected. User-controlled input in filesystem operations allows attackers to access files outside intended directories. This can lead to unauthorized access to sensitive system files and exposure of confidential data. To remediate: Use path.basename() to strip directory components, explicitly check for path traversal sequences "..", and validate final paths remain within authorized directories. Learn more - https://cwe.mitre.org/data/definitions/22.html

Severity: High

Comment thread scripts/rag-ingest.ts

async function embedBatch(texts: string[]): Promise<number[][]> {
const res = await fetch(
`https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/ai/run/${EMBED_MODEL}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description: Server-Side Request Forgery (SSRF) vulnerability detected.
Untrusted user input is being used in a network request without proper validation.
This can allow attackers to craft requests to internal systems, access metadata services,
or perform internal port scans. To fix this issue, strictly validate and sanitize the input URL
using a library like node:url for parsing, enforce an allowlist of trusted domains,
and block access to private IP ranges (e.g., 127.0.0.1, 169.254.169.254).
Learn more: https://owasp.org/www-community/attacks/Server_Side_Request_Forgery

Severity: High

Comment thread scripts/rag-ingest.ts
async function buildItems(pages: PageRef[]): Promise<Item[]> {
const items: Item[] = [];
for (const p of pages) {
const raw = await fs.readFile(p.filePath, "utf8");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description: Path traversal vulnerability detected. User-controlled input in filesystem operations allows attackers to access files outside intended directories. This can lead to unauthorized access to sensitive system files and exposure of confidential data. To remediate: Use path.basename() to strip directory components, explicitly check for path traversal sequences "..", and validate final paths remain within authorized directories. Learn more - https://cwe.mitre.org/data/definitions/22.html

Severity: High

Comment thread src/app/api/chat/route.ts Outdated
const messages = body.messages ?? [];

const query = buildRetrievalQuery(messages);
const retrieved = await fetch(`${RAG_URL}/retrieve`, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description: Server-Side Request Forgery (SSRF) vulnerability detected.
Untrusted user input is being used in a network request without proper validation.
This can allow attackers to craft requests to internal systems, access metadata services,
or perform internal port scans. To fix this issue, strictly validate and sanitize the input URL
using a library like node:url for parsing, enforce an allowlist of trusted domains,
and block access to private IP ranges (e.g., 127.0.0.1, 169.254.169.254).
Learn more: https://owasp.org/www-community/attacks/Server_Side_Request_Forgery

Severity: High

@amazon-inspector-n-virginia

Copy link
Copy Markdown

✅ I finished the code review, and left comments with the issues I found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants