Skip to content

v0.5.81: traces fix, additional confluence tools, azure anthropic support, opus 4.6 - #3146

Merged
waleedlatif1 merged 5 commits into
mainfrom
staging
Feb 5, 2026
Merged

waleedlatif1 merged 5 commits into
mainfrom
staging

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

waleedlatif1 and others added 4 commits February 4, 2026 19:32
* feat(confluence): added more confluence endpoints

* update license

* updated

* updated docs
…n cleanups (#3141)

* fix(onedrive): canonical param required validation

* fix onedrive

* cleanup canonical tool param resolution code

* fix type

* fix jira type checks

* remove manual validations
@vercel

vercel Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 5, 2026 6:52pm

Request Review

Comment on lines +92 to +98
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

In general, to fix this type of issue you must ensure that any user‑controlled parts of an outbound URL are either (a) not used in security‑sensitive positions like the hostname, or (b) strictly validated/normalized against an allow‑list before being interpolated. For path segments, that usually means enforcing a very restrictive character set (e.g., alphanumeric only), a reasonable length limit, and explicitly rejecting characters that could enable path traversal or URL confusion (/, \, ., :, ?, #, etc.).

For this specific code, the best minimal fix is to add an extra local safety check on cloudId right after it is determined, before it is used to construct url. This check should ensure that cloudId is non‑empty and matches a safe pattern such as /^[a-zA-Z0-9-]+$/ and is within a reasonable length, and return a 400 error if it fails. This is complementary to the existing validateJiraCloudId call and does not change normal behavior for valid Confluence cloud IDs; it just guards against any malformed or malicious values that might slip through or in case validateJiraCloudId is looser than expected. No other logic in the function needs to change, and no new external dependencies are required, as we can use a simple regular expression.

Concretely:

  • In apps/sim/app/api/tools/confluence/blogposts/route.ts, in the GET handler, immediately after the cloudIdValidation block, insert a new validation block that:
    • Checks that cloudId is a string.
    • Checks that it matches a strict regex allow‑list for safe characters.
    • Optionally checks max length.
    • Returns a NextResponse.json with status 400 if invalid.
  • Keep the rest of the code (query parameter building and fetch(url, ...)) unchanged.
Suggested changeset 1
apps/sim/app/api/tools/confluence/blogposts/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/blogposts/route.ts b/apps/sim/app/api/tools/confluence/blogposts/route.ts
--- a/apps/sim/app/api/tools/confluence/blogposts/route.ts
+++ b/apps/sim/app/api/tools/confluence/blogposts/route.ts
@@ -72,6 +72,12 @@
       return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
     }
 
+    // Additional strict allow-list validation to ensure cloudId is safe to use in the URL path
+    const safeCloudIdPattern = /^[a-zA-Z0-9-]+$/
+    if (typeof cloudId !== 'string' || cloudId.length === 0 || cloudId.length > 255 || !safeCloudIdPattern.test(cloudId)) {
+      return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
+    }
+
     const queryParams = new URLSearchParams()
     queryParams.append('limit', String(Math.min(Number(limit), 250)))
 
EOF
@@ -72,6 +72,12 @@
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}

// Additional strict allow-list validation to ensure cloudId is safe to use in the URL path
const safeCloudIdPattern = /^[a-zA-Z0-9-]+$/
if (typeof cloudId !== 'string' || cloudId.length === 0 || cloudId.length > 255 || !safeCloudIdPattern.test(cloudId)) {
return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
}

const queryParams = new URLSearchParams()
queryParams.append('limit', String(Math.min(Number(limit), 250)))

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +56 to +62
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

General approach: Ensure that any user input incorporated into the URL path is strictly validated to an expected, safe format that cannot change the URL structure. For this endpoint, pageId should be restricted to the formats actually used by Confluence (commonly numeric IDs). By enforcing a numeric-only pattern and/or reusing a dedicated “Confluence page ID” validator, we prevent characters like /, ?, #, or % from entering the path, eliminating realistic SSRF/path-traversal risk while keeping the existing functionality.

Best concrete fix without changing functionality: Replace the generic validateAlphanumericId call on pageId with a stricter numeric validation performed locally in this file. Because we cannot modify other files, we’ll add a small helper in this file that checks pageId against a numeric regex and a sane length limit (e.g., up to 20 digits, which is more than enough for Confluence IDs). If the validation fails, we return a 400 error, just like the existing code. The rest of the logic remains unchanged, including the construction of the Atlassian URL and handling of cloudId and limit.

Concrete edits in apps/sim/app/api/tools/confluence/page-ancestors/route.ts:

  • Add a local validateConfluencePageId helper function near the top of the file (below the logger definition) that:
    • Accepts pageId: string.
    • Ensures it matches /^[0-9]+$/ and has a maximum length, e.g., 20.
    • Returns an object like { isValid: boolean, error?: string } to match the style of existing validators.
  • Replace the existing validateAlphanumericId(pageId, 'pageId', 255) call and its use with the new validateConfluencePageId(pageId) call.

No new imports are required; we can implement the helper directly in this file.

Suggested changeset 1
apps/sim/app/api/tools/confluence/page-ancestors/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/page-ancestors/route.ts b/apps/sim/app/api/tools/confluence/page-ancestors/route.ts
--- a/apps/sim/app/api/tools/confluence/page-ancestors/route.ts
+++ b/apps/sim/app/api/tools/confluence/page-ancestors/route.ts
@@ -6,6 +6,22 @@
 
 const logger = createLogger('ConfluencePageAncestorsAPI')
 
+function validateConfluencePageId(pageId: string): { isValid: boolean; error?: string } {
+  // Confluence content IDs are numeric. Restricting to digits prevents path traversal
+  // or other URL-structure manipulation when `pageId` is interpolated into the path.
+  const maxLength = 20
+  if (typeof pageId !== 'string' || pageId.length === 0) {
+    return { isValid: false, error: 'pageId must be a non-empty string' }
+  }
+  if (pageId.length > maxLength) {
+    return { isValid: false, error: `pageId must be at most ${maxLength} characters long` }
+  }
+  if (!/^[0-9]+$/.test(pageId)) {
+    return { isValid: false, error: 'pageId must contain only digits' }
+  }
+  return { isValid: true }
+}
+
 export const dynamic = 'force-dynamic'
 
 /**
@@ -34,7 +50,7 @@
       return NextResponse.json({ error: 'Page ID is required' }, { status: 400 })
     }
 
-    const pageIdValidation = validateAlphanumericId(pageId, 'pageId', 255)
+    const pageIdValidation = validateConfluencePageId(pageId)
     if (!pageIdValidation.isValid) {
       return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
     }
EOF
@@ -6,6 +6,22 @@

const logger = createLogger('ConfluencePageAncestorsAPI')

function validateConfluencePageId(pageId: string): { isValid: boolean; error?: string } {
// Confluence content IDs are numeric. Restricting to digits prevents path traversal
// or other URL-structure manipulation when `pageId` is interpolated into the path.
const maxLength = 20
if (typeof pageId !== 'string' || pageId.length === 0) {
return { isValid: false, error: 'pageId must be a non-empty string' }
}
if (pageId.length > maxLength) {
return { isValid: false, error: `pageId must be at most ${maxLength} characters long` }
}
if (!/^[0-9]+$/.test(pageId)) {
return { isValid: false, error: 'pageId must contain only digits' }
}
return { isValid: true }
}

export const dynamic = 'force-dynamic'

/**
@@ -34,7 +50,7 @@
return NextResponse.json({ error: 'Page ID is required' }, { status: 400 })
}

const pageIdValidation = validateAlphanumericId(pageId, 'pageId', 255)
const pageIdValidation = validateConfluencePageId(pageId)
if (!pageIdValidation.isValid) {
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
}
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +60 to +66
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

In general, to fix SSRF issues you must ensure that user input cannot affect the hostname or scheme, and that any user-controlled path segments are tightly validated or mapped from an allow‑list. In this code, the host is already hard-coded, so the main remaining step is to guarantee that pageId and cloudId are strictly constrained to safe formats and cannot contain path separators, query delimiters, or other characters that could change the target endpoint.

The best minimal fix here is to add explicit, local validation for pageId and cloudId in this route, using strict regular expressions that only allow the exact formats expected by Atlassian: for example, Confluence page IDs are numeric, and cloud IDs are UUID-like lowercase hex with dashes. Even if the existing shared validators already enforce something similar, adding explicit checks in this file is both safe and sufficient to convince CodeQL that the values are not arbitrary. If the provided values do not match the expected pattern, we immediately return a 400 error instead of performing the fetch. This does not change existing, legitimate functionality (valid requests still pass) but prevents malformed or malicious IDs from being used in the URL.

Concretely:

  • After destructuring the body and the existing validateAlphanumericId / validateJiraCloudId checks, add:
    • A regex check for pageId, e.g. /^[0-9]+$/.
    • A regex check for cloudId, e.g. /^[a-f0-9-]{36}$/ (or tighter UUID v4 pattern, but this is usually enough).
  • If either check fails, return a 400 error JSON response.
    No new imports are required; we can use JavaScript’s built-in RegExp and string methods.

Suggested changeset 1
apps/sim/app/api/tools/confluence/page-children/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/page-children/route.ts b/apps/sim/app/api/tools/confluence/page-children/route.ts
--- a/apps/sim/app/api/tools/confluence/page-children/route.ts
+++ b/apps/sim/app/api/tools/confluence/page-children/route.ts
@@ -39,6 +39,11 @@
       return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
     }
 
+    // Ensure pageId has a strict, expected format (numeric Confluence page ID)
+    if (!/^[0-9]+$/.test(pageId)) {
+      return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
+    }
+
     const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -46,6 +51,11 @@
       return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
     }
 
+    // Ensure cloudId has a strict, expected format (UUID-like Atlassian cloud ID)
+    if (!/^[a-f0-9-]{36}$/.test(cloudId)) {
+      return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
+    }
+
     const queryParams = new URLSearchParams()
     queryParams.append('limit', String(Math.min(limit, 250)))
 
EOF
@@ -39,6 +39,11 @@
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
}

// Ensure pageId has a strict, expected format (numeric Confluence page ID)
if (!/^[0-9]+$/.test(pageId)) {
return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -46,6 +51,11 @@
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}

// Ensure cloudId has a strict, expected format (UUID-like Atlassian cloud ID)
if (!/^[a-f0-9-]{36}$/.test(cloudId)) {
return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
}

const queryParams = new URLSearchParams()
queryParams.append('limit', String(Math.min(limit, 250)))

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +89 to +95
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

General approach: ensure that any user input embedded in the URL path is strictly constrained to a known-safe character set and expected shape, not just “non-empty string”, so that it cannot introduce /, ?, #, or other characters that could alter the structure of the URL. Since the hostname is already hard-coded, we mainly need to ensure the path segments (cloudId, pageId) and any relevant query parameters cannot be maliciously structured.

Best concrete fix here without changing external behavior: add explicit, local validation of pageId (and optionally cloudId) right before they are interpolated into the URL, using simple regular expressions that only permit the characters we actually expect. For example, for Confluence page IDs, this is typically numeric; we can enforce ^[0-9]+$. For Jira/Confluence cloud IDs, Atlassian uses UUID-like or hex-like identifiers; if we want to stay conservative without knowledge of validateJiraCloudId, we can restrict to alphanumeric and dashes: ^[A-Za-z0-9-]+$. If the values fail these stricter checks, return a 400 error. This preserves existing functionality for valid inputs while giving a clear, local guarantee to CodeQL (and to reviewers) that the path segments cannot contain path traversal characters.

Concretely, in apps/sim/app/api/tools/confluence/page-properties/route.ts inside GET:

  • After the existing pageIdValidation block and before constructing cloudId, add a regex-based sanity check on pageId (e.g. numeric-only).
  • After computing cloudId and checking it with validateJiraCloudId, add a regex-based sanity check on cloudId that restricts it to [A-Za-z0-9-]+.
  • Keep the fetch call as is but now backed by these explicit constraints, which removes the conditions under which user input could meaningfully affect the URL structure.

No new imports are needed; we can use built-in RegExp/.test.

Suggested changeset 1
apps/sim/app/api/tools/confluence/page-properties/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/page-properties/route.ts b/apps/sim/app/api/tools/confluence/page-properties/route.ts
--- a/apps/sim/app/api/tools/confluence/page-properties/route.ts
+++ b/apps/sim/app/api/tools/confluence/page-properties/route.ts
@@ -72,6 +72,11 @@
       return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
     }
 
+    // Ensure pageId is safe to embed in a URL path segment (numeric-only to match Confluence IDs)
+    if (!/^[0-9]+$/.test(pageId)) {
+      return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
+    }
+
     const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -79,6 +84,11 @@
       return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
     }
 
+    // Ensure cloudId is safe to embed in a URL path segment
+    if (!/^[A-Za-z0-9-]+$/.test(cloudId)) {
+      return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
+    }
+
     const queryParams = new URLSearchParams()
     queryParams.append('limit', String(Math.min(Number(limit), 250)))
     if (cursor) {
EOF
@@ -72,6 +72,11 @@
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
}

// Ensure pageId is safe to embed in a URL path segment (numeric-only to match Confluence IDs)
if (!/^[0-9]+$/.test(pageId)) {
return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -79,6 +84,11 @@
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}

// Ensure cloudId is safe to embed in a URL path segment
if (!/^[A-Za-z0-9-]+$/.test(cloudId)) {
return NextResponse.json({ error: 'Invalid cloudId format' }, { status: 400 })
}

const queryParams = new URLSearchParams()
queryParams.append('limit', String(Math.min(Number(limit), 250)))
if (cursor) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +64 to +70
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

In general, to fix SSRF concerns for outbound HTTP requests, ensure any user input used in a URL is (1) not allowed to affect the scheme or host, and (2) tightly validated or normalized when used in the path/query so that characters enabling path traversal or redirection (/, \, ?, #, :, %, etc.) are rejected. Prefer selecting from a whitelist of allowed patterns.

For this specific code, the host is already fixed (https://api.atlassian.com), so we only need to harden the validation of pageId (and optionally versionNumber) before including them in the URL. The least invasive fix, without altering existing behavior, is:

  • Add a local, explicit validation for pageId that permits only a strict, URL-safe identifier pattern suitable for Confluence page IDs (e.g., digits or a limited [-A-Za-z0-9] set) and enforces length.
  • Optionally, add a simple numeric check for versionNumber (if it is expected to be numeric).
  • If the values fail these new checks, return 400 Bad Request instead of calling fetch.

We will implement this entirely within apps/sim/app/api/tools/confluence/page-versions/route.ts:

  1. Add a small helper function isSafeConfluencePageId (no new imports needed) that uses a regular expression to constrain allowed characters and length.
  2. After the existing validateAlphanumericId check for pageId, add an additional guard that calls isSafeConfluencePageId(pageId) and rejects unsafe values with a 400 response.
  3. Similarly, ensure versionNumber is a positive integer before using it in the URL when present.

This keeps existing logic and logging intact, only adding extra validation prior to constructing the URL that CodeQL flags.

Suggested changeset 1
apps/sim/app/api/tools/confluence/page-versions/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/page-versions/route.ts b/apps/sim/app/api/tools/confluence/page-versions/route.ts
--- a/apps/sim/app/api/tools/confluence/page-versions/route.ts
+++ b/apps/sim/app/api/tools/confluence/page-versions/route.ts
@@ -6,6 +6,14 @@
 
 const logger = createLogger('ConfluencePageVersionsAPI')
 
+// Restrict pageId used in external URLs to a safe, URL-path-friendly pattern.
+// This is an extra defense-in-depth guard on top of validateAlphanumericId.
+function isSafeConfluencePageId(id: string): boolean {
+  // Allow only alphanumeric characters and dashes/underscores, 1–255 chars.
+  // This prevents characters that could alter the URL structure (such as '/', '?', ':', '#', '%').
+  return /^[A-Za-z0-9_-]{1,255}$/.test(id)
+}
+
 export const dynamic = 'force-dynamic'
 
 /**
@@ -48,6 +56,11 @@
       return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
     }
 
+    // Extra SSRF hardening: ensure pageId cannot alter the URL structure.
+    if (!isSafeConfluencePageId(pageId)) {
+      return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
+    }
+
     const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -57,7 +70,12 @@
 
     // If versionNumber is provided, get specific version
     if (versionNumber !== undefined && versionNumber !== null) {
-      const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}/versions/${versionNumber}`
+      // Basic validation to ensure versionNumber is a positive integer when used in the URL.
+      const parsedVersion = Number(versionNumber)
+      if (!Number.isInteger(parsedVersion) || parsedVersion <= 0) {
+        return NextResponse.json({ error: 'Invalid versionNumber' }, { status: 400 })
+      }
+      const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}/versions/${parsedVersion}`
 
       logger.info(`Fetching version ${versionNumber} for page ${pageId}`)
 
EOF
@@ -6,6 +6,14 @@

const logger = createLogger('ConfluencePageVersionsAPI')

// Restrict pageId used in external URLs to a safe, URL-path-friendly pattern.
// This is an extra defense-in-depth guard on top of validateAlphanumericId.
function isSafeConfluencePageId(id: string): boolean {
// Allow only alphanumeric characters and dashes/underscores, 1–255 chars.
// This prevents characters that could alter the URL structure (such as '/', '?', ':', '#', '%').
return /^[A-Za-z0-9_-]{1,255}$/.test(id)
}

export const dynamic = 'force-dynamic'

/**
@@ -48,6 +56,11 @@
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
}

// Extra SSRF hardening: ensure pageId cannot alter the URL structure.
if (!isSafeConfluencePageId(pageId)) {
return NextResponse.json({ error: 'Invalid pageId format' }, { status: 400 })
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -57,7 +70,12 @@

// If versionNumber is provided, get specific version
if (versionNumber !== undefined && versionNumber !== null) {
const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}/versions/${versionNumber}`
// Basic validation to ensure versionNumber is a positive integer when used in the URL.
const parsedVersion = Number(versionNumber)
if (!Number.isInteger(parsedVersion) || parsedVersion <= 0) {
return NextResponse.json({ error: 'Invalid versionNumber' }, { status: 400 })
}
const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}/versions/${parsedVersion}`

logger.info(`Fetching version ${versionNumber} for page ${pageId}`)

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +77 to +83
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

To fix the problem, we should ensure that the URL used in fetch does not depend on attacker-controlled values in a way that could target unintended resources. The simplest and safest approach here is to remove the dependency on the user-provided cloudId and always derive cloudId on the server from the domain using the existing helper getConfluenceCloudId. That way, even if a client sends a malicious cloudId, it is ignored; only the server’s mapping from domain to cloudId is used.

Concretely, in apps/sim/app/api/tools/confluence/search-in-space/route.ts:

  • Remove destructuring of cloudId: providedCloudId from the request body.
  • Change the line that computes cloudId from:
    const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
    to:
    const cloudId = await getConfluenceCloudId(domain, accessToken)
  • Leave the subsequent validateJiraCloudId(cloudId, 'cloudId') in place to ensure the server-resolved ID is valid.
  • No new imports or helper methods are needed; we reuse getConfluenceCloudId and existing validation.

This eliminates the data flow from untrusted input into the URL path while preserving existing behavior for valid clients (they already need to supply a correct domain and accessToken).

Suggested changeset 1
apps/sim/app/api/tools/confluence/search-in-space/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/search-in-space/route.ts b/apps/sim/app/api/tools/confluence/search-in-space/route.ts
--- a/apps/sim/app/api/tools/confluence/search-in-space/route.ts
+++ b/apps/sim/app/api/tools/confluence/search-in-space/route.ts
@@ -24,7 +24,6 @@
       accessToken,
       spaceKey,
       query,
-      cloudId: providedCloudId,
       limit = 25,
       contentType,
     } = body
@@ -46,7 +45,7 @@
       return NextResponse.json({ error: spaceKeyValidation.error }, { status: 400 })
     }
 
-    const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
+    const cloudId = await getConfluenceCloudId(domain, accessToken)
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
     if (!cloudIdValidation.isValid) {
EOF
@@ -24,7 +24,6 @@
accessToken,
spaceKey,
query,
cloudId: providedCloudId,
limit = 25,
contentType,
} = body
@@ -46,7 +45,7 @@
return NextResponse.json({ error: spaceKeyValidation.error }, { status: 400 })
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
const cloudId = await getConfluenceCloudId(domain, accessToken)

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
if (!cloudIdValidation.isValid) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +77 to +83
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

In general, to fix SSRF-like findings where user input is used in a request URL path, restrict that input to a strict, expected format and/or map it from a safe, server-side–controlled set before interpolating it into the URL. The key is to ensure user input cannot alter the target host and cannot be abused to target arbitrary or unintended resources.

For this specific code, the hostname is already fixed to Atlassian’s API, so the remaining step is to strictly validate spaceId against the format Confluence actually uses for space IDs (typically short uppercase alphanumeric keys without spaces or punctuation) rather than relying on a very permissive “alphanumeric up to length 255” check. The minimal change, without altering existing functionality too much, is to add an explicit format check (e.g., a regular expression like /^[A-Z0-9]+$/) before using spaceId in the URL. If it fails, return a 400 response. This confines spaceId to benign values and addresses CodeQL’s concern that a raw user string is being used directly in the URL path.

Concretely, in apps/sim/app/api/tools/confluence/space-blogposts/route.ts, after the existing validateAlphanumericId(spaceId, 'spaceId', 255) check (around lines 46–49), add a stricter validation: test spaceId against a regex that matches only the allowed Confluence space key pattern (for example uppercase letters, digits, and maybe -), and reject invalid values. No additional imports are needed: TypeScript/JavaScript’s built-in RegExp suffices. The rest of the logic (constructing url and calling fetch) remains unchanged.

Suggested changeset 1
apps/sim/app/api/tools/confluence/space-blogposts/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/space-blogposts/route.ts b/apps/sim/app/api/tools/confluence/space-blogposts/route.ts
--- a/apps/sim/app/api/tools/confluence/space-blogposts/route.ts
+++ b/apps/sim/app/api/tools/confluence/space-blogposts/route.ts
@@ -48,6 +48,16 @@
       return NextResponse.json({ error: spaceIdValidation.error }, { status: 400 })
     }
 
+    // Additional strict validation for Confluence space key format to avoid using
+    // arbitrary user-controlled values in the request path.
+    const spaceKeyPattern = /^[A-Z0-9-]+$/
+    if (!spaceKeyPattern.test(spaceId)) {
+      return NextResponse.json(
+        { error: 'Invalid spaceId format. Expected uppercase letters, digits, or hyphens.' },
+        { status: 400 },
+      )
+    }
+
     const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
EOF
@@ -48,6 +48,16 @@
return NextResponse.json({ error: spaceIdValidation.error }, { status: 400 })
}

// Additional strict validation for Confluence space key format to avoid using
// arbitrary user-controlled values in the request path.
const spaceKeyPattern = /^[A-Z0-9-]+$/
if (!spaceKeyPattern.test(spaceId)) {
return NextResponse.json(
{ error: 'Invalid spaceId format. Expected uppercase letters, digits, or hyphens.' },
{ status: 400 },
)
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines +77 to +83
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).

Copilot Autofix

AI 10 months ago

In general, to mitigate SSRF when building URLs from user input, ensure that any user-controlled components are either (a) mapped to fixed known values (allow‑list) or (b) strictly validated and encoded so they cannot alter the intended target or path structure. Even when the hostname is fixed, path components should be constrained (e.g., only allow safe characters, length limits, and no slashes or .. segments).

For this specific code, the best fix without changing functionality is to add a local, explicit validation/normalization step for spaceId right before it is used in the URL. We already call validateAlphanumericId, but CodeQL does not know its guarantees. We can add a small, clearly safe check to ensure spaceId only contains alphanumerics and a small set of safe punctuation characters that match Confluence space IDs (commonly letters, digits, -, _). If the input fails this check, we return a 400 error. This prevents any possibility of including /, \, ?, #, or other characters that might affect URL structure, and it makes the safety properties obvious to both humans and the static analyzer.

Concretely:

  • In apps/sim/app/api/tools/confluence/space-pages/route.ts, after the existing spaceIdValidation block (lines 46–49) and before const cloudId = ... (line 51), add a stricter regex check on spaceId (e.g., /^[A-Za-z0-9_-]{1,255}$/).
  • If the check fails, return 400 with a clear error message.
  • No new imports are required, as we can use built-in RegExp.

This leaves the existing behavior unchanged for valid IDs, but rejects any malicious or malformed values before they reach fetch.


Suggested changeset 1
apps/sim/app/api/tools/confluence/space-pages/route.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/sim/app/api/tools/confluence/space-pages/route.ts b/apps/sim/app/api/tools/confluence/space-pages/route.ts
--- a/apps/sim/app/api/tools/confluence/space-pages/route.ts
+++ b/apps/sim/app/api/tools/confluence/space-pages/route.ts
@@ -48,6 +48,16 @@
       return NextResponse.json({ error: spaceIdValidation.error }, { status: 400 })
     }
 
+    // Additional strict validation to ensure spaceId cannot affect URL structure
+    // Allow only letters, digits, underscore, and hyphen, up to 255 characters.
+    const safeSpaceIdPattern = /^[A-Za-z0-9_-]{1,255}$/
+    if (!safeSpaceIdPattern.test(spaceId)) {
+      return NextResponse.json(
+        { error: 'Invalid spaceId format. Only letters, digits, underscore, and hyphen are allowed.' },
+        { status: 400 },
+      )
+    }
+
     const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
 
     const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
EOF
@@ -48,6 +48,16 @@
return NextResponse.json({ error: spaceIdValidation.error }, { status: 400 })
}

// Additional strict validation to ensure spaceId cannot affect URL structure
// Allow only letters, digits, underscore, and hyphen, up to 255 characters.
const safeSpaceIdPattern = /^[A-Za-z0-9_-]{1,255}$/
if (!safeSpaceIdPattern.test(spaceId)) {
return NextResponse.json(
{ error: 'Invalid spaceId format. Only letters, digits, underscore, and hyphen are allowed.' },
{ status: 400 },
)
}

const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))

const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
…r chat completions API, added opus 4.6 (#3145)

* feat(azure): added azure anthropic, added backwards compat support for chat completions API, added opus 4.6

* added max thinking level

* update tests

* ack comments

* update cql validation
@waleedlatif1
waleedlatif1 marked this pull request as ready for review February 5, 2026 18:56
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This release bundles multiple feature additions and important bug fixes across the platform.

Major Features:

  • Added Azure Anthropic provider support for accessing Claude models via Azure AI Foundry, with proper endpoint configuration and authentication
  • Added support for Claude Opus 4.6 with adaptive thinking capability (effort-based instead of token-budget-based)
  • Expanded Confluence integration with 15+ new tools including blog posts, comments, attachments, labels, page properties, and advanced search

Critical Bug Fixes:

  • Fixed trace spans tool call matching for successive identical tool calls - previously only the first tool call's inputs were displayed for repeated tools
  • Fixed input validation to properly check canonical parameter IDs when params have been deduplicated
  • Fixed client workflow execution to always send complete workflow state (blocks, edges, loops, parallels) to the executor

Refactoring:

  • Extracted shared Anthropic provider logic into anthropic/core.ts for reuse between standard and Azure providers
  • Moved branding/whitelabeling logic from lib/branding to ee/whitelabeling for better enterprise feature separation
  • Created shared branding types in lib/branding/types.ts for cross-module compatibility

Confidence Score: 5/5

  • This PR is safe to merge with no critical issues found
  • All changes are well-structured bug fixes and feature additions with proper error handling, type safety, and backwards compatibility maintained throughout
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/logs/execution/trace-spans/trace-spans.ts Fixed tool call matching for successive identical tool calls using index tracking
apps/sim/providers/azure-anthropic/index.ts Added new Azure Anthropic provider with proper endpoint configuration
apps/sim/providers/anthropic/core.ts Extracted shared Anthropic provider logic, added Opus 4.6 adaptive thinking support
apps/sim/providers/models.ts Added claude-opus-4-6 and azure-anthropic models with pricing and capabilities
apps/sim/serializer/index.ts Fixed validation to check canonical param IDs for missing field detection
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts Fixed workflow state override to always send complete state to executor
apps/sim/ee/whitelabeling/branding.ts Moved branding logic to EE module for better separation of concerns
apps/sim/tools/confluence/index.ts Added 15+ new Confluence tools including blog posts, comments, attachments, labels

Sequence Diagram

sequenceDiagram
    participant Client
    participant Executor
    participant Provider
    participant AnthropicCore
    participant AzureAI
    participant TraceSpans

    Note over Client,TraceSpans: Azure Anthropic Integration Flow
    
    Client->>Executor: Execute workflow with azure-anthropic model
    Executor->>Provider: Route to azure-anthropic provider
    Provider->>Provider: Strip azure-anthropic/ prefix
    Provider->>Provider: Construct Azure endpoint URL
    Provider->>AnthropicCore: executeAnthropicProviderRequest()
    AnthropicCore->>AnthropicCore: Check for Opus 4.6 adaptive thinking
    AnthropicCore->>AzureAI: Create Anthropic client with custom baseURL
    AzureAI-->>AnthropicCore: Client with api-key header
    AnthropicCore->>AzureAI: Send request with thinking config
    AzureAI-->>AnthropicCore: Response with tool calls
    
    Note over AnthropicCore: Tool Call Loop
    loop For each tool iteration
        AnthropicCore->>AnthropicCore: Track tool call timing
        AnthropicCore->>Executor: Execute tool
        Executor-->>AnthropicCore: Tool result
    end
    
    AnthropicCore-->>Provider: Complete response with timeSegments
    Provider-->>Executor: Response with timing data
    
    Note over Executor,TraceSpans: Trace Span Generation
    Executor->>TraceSpans: buildTraceSpans(executionResult)
    TraceSpans->>TraceSpans: Group tool calls by name
    TraceSpans->>TraceSpans: Match segments to calls by index
    TraceSpans-->>Executor: Trace spans with correct tool inputs
    
    Note over Client,Executor: Workflow State Override Fix
    Client->>Client: Prepare execution state
    Client->>Client: Ensure complete state (blocks, edges, loops, parallels)
    Client->>Executor: Send with workflowStateOverride
    Executor->>Executor: Use client state for execution
Loading

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

const body = await request.json()

// Check if this is a create or get request
if (body.title && body.content && body.spaceId) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ambiguous request handling may create unintended blog posts

Medium Severity

The POST endpoint uses body.title && body.content && body.spaceId to decide between creating a blog post versus retrieving one by blogPostId. If a request contains both a blogPostId AND the creation fields (title, content, spaceId), the create path takes precedence and the blogPostId is silently ignored. This could cause users to accidentally create duplicate blog posts when intending to retrieve or reference an existing one.

Fix in Cursor Fix in Web


const searchParams = new URLSearchParams({
cql: `text ~ "${query}"`,
cql: `text ~ "${escapeCqlValue(query)}"`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing string type check causes crash on non-string input

Medium Severity

The new escapeCqlValue function calls .replace() on its input, which requires a string. However, query is only validated for truthiness (if (!query)), not type. If a client sends query: 123 (number) or query: {} (object), the code throws a TypeError since these types don't have a .replace() method. Previously, query was interpolated directly into a template literal which auto-converts to string. The same issue affects query and contentType in the search-in-space route.

Additional Locations (1)

Fix in Cursor Fix in Web

pageId,
nextCursor: data._links?.next
? new URL(data._links.next, 'https://placeholder').searchParams.get('cursor')
: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated cursor extraction logic across Confluence routes

Medium Severity

The cursor extraction pattern new URL(data._links.next, 'https://placeholder').searchParams.get('cursor') is duplicated across 10+ Confluence route files. Extract this to a utility function like extractNextCursor(data) in the existing @/tools/confluence/utils.ts file.

Fix in Cursor Fix in Web

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}

const escapeCqlValue = (value: string) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated escapeCqlValue function across search routes

Medium Severity

The escapeCqlValue function is defined identically in both search/route.ts (line 45) and search-in-space/route.ts (line 56). This utility function should be extracted to @/tools/confluence/utils.ts where other shared Confluence utilities already exist.

Fix in Cursor Fix in Web

@waleedlatif1
waleedlatif1 merged commit 1a66d48 into main Feb 5, 2026

This branch was previously deployed

1 inactive deployment
Preview — 1d4d61a1 Deployed Feb 5, 2026 by vercel[bot]
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.

3 participants