René's URL Explorer Experiment


Title: fix(security): KB fileUrl LFI, MCP/Agiloft SSRF pinning, form OTP, KB authz by waleedlatif1 · Pull Request #4639 · simstudioai/sim · GitHub

Open Graph Title: fix(security): KB fileUrl LFI, MCP/Agiloft SSRF pinning, form OTP, KB authz by waleedlatif1 · Pull Request #4639 · simstudioai/sim

X Title: fix(security): KB fileUrl LFI, MCP/Agiloft SSRF pinning, form OTP, KB authz by waleedlatif1 · Pull Request #4639 · simstudioai/sim

Description: Summary Bundled security hardening across multiple surfaces: KB fileUrl LFI: POST /api/knowledge/[id]/documents/upsert previously accepted any non-empty string for fileUrl, which the background processor then passed to fs.readFile / parseFile, allowing authenticated arbitrary local file reads (e.g. /app/.env, /etc/passwd). Now gated at the boundary via knowledgeDocumentFileUrlSchema (only data: URIs or http(s):// URLs); defense-in-depth in document-processor.ts throws on any other scheme. KB authorization & transaction hardening: introduces KnowledgeBasePermissionError, tightens permission checks, and wraps multi-step KB mutations in transactions. MCP DNS-rebinding (SSRF): outbound MCP calls now go through pinned-fetch.ts (undici Agent with a pinned lookup) so the host the policy validated is the host actually connected to. Agiloft SSRF/DNS pinning: resolveAgiloftInstance + pinned fetch for attach / retrieve routes. Grafana baseUrl validation: update_alert_rule / update_dashboard route through secureFetchWithValidation. Form email-OTP flow: new POST /api/form/[identifier]/otp route + email-auth.tsx UI; shared OTP module under lib/core/security/otp.ts keyed by DeploymentKind, with the chat OTP route refactored to consume it. Audit script ratchet: bumps the API-validation baseline by one route for the new form OTP endpoint. Test plan bun run check:api-validation:strict passes Lint passes 194 unit tests pass across affected areas (contracts, route handlers, services, pinned-fetch, OTP) Production data audited via PlanetScale MCP — 10,501 legitimate relative /api/files/serve/... rows have zero completed status (already failing under the old fs.readFile path); change is strictly a clearer error, not a regression Backwards-compat verified end-to-end on staging 🤖 Generated with Claude Code

Open Graph Description: Summary Bundled security hardening across multiple surfaces: KB fileUrl LFI: POST /api/knowledge/[id]/documents/upsert previously accepted any non-empty string for fileUrl, which the background pr...

X Description: Summary Bundled security hardening across multiple surfaces: KB fileUrl LFI: POST /api/knowledge/[id]/documents/upsert previously accepted any non-empty string for fileUrl, which the background pr...

Opengraph URL: https://github.com/simstudioai/sim/pull/4639

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:16720e02-4a82-9623-152d-3452b7e0e0d7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBDD2:D16D6:B7CF27:FD0BF3:6AFB569D
html-safe-nonce41be56316e541c5d646b0a5e0686092286b6d6d72141a856504dc6be82250ea7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREQyOkQxNkQ2OkI3Q0YyNzpGRDBCRjM6NkFGQjU2OUQiLCJ2aXNpdG9yX2lkIjoiNjkzMTkwMzUyNDc2NjQzOTA2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac207649e831601c6d90b55c97be28ec3c241fc75e2f06a1ac9ed610b0c4d10769
hovercard-subject-tagpull_request:3696375087
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/4639/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Bundled security hardening across multiple surfaces: KB fileUrl LFI: POST /api/knowledge/[id]/documents/upsert previously accepted any non-empty string for fileUrl, which the background pr...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/4639/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F4639%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F4639%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/4639/files
Reloadhttps://github.com/simstudioai/sim/pull/4639/files
Reloadhttps://github.com/simstudioai/sim/pull/4639/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
waleedlatif1/fix-kb-fileurl-lfihttps://github.com/simstudioai/sim/tree/waleedlatif1/fix-kb-fileurl-lfi
Conversation 23 https://github.com/simstudioai/sim/pull/4639
Commits 6 https://github.com/simstudioai/sim/pull/4639/commits
Checks 13 https://github.com/simstudioai/sim/pull/4639/checks
Files changed https://github.com/simstudioai/sim/pull/4639/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4639/files
fix(security): KB fileUrl LFI, MCP/Agiloft SSRF pinning, form OTP, KB authz https://github.com/simstudioai/sim/pull/4639/files#top
Show all changes 6 commits https://github.com/simstudioai/sim/pull/4639/files
4d3e1b3 fix(security): KB fileUrl LFI, MCP/Agiloft SSRF pinning, form OTP, KB… waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/4d3e1b3787629494eebf4bf0fb9aeddea3fea744
ad80c30 fix(otp): don't leak caught error.message; fail-closed on DB retry ex… waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/ad80c3029171f1356c7793f95ba957843dbc2d1a
9fe9cb2 fix(mcp): use undici fetch directly in pinned-fetch for typed dispatcher waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/9fe9cb238fadf0e2e131601883fb51c930927cb4
2b06b80 fix(build): keep agiloft/grafana tool configs client-safe waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/2b06b80da07fb3c663e923f9211ac214e4e0b1ec
14bfcb7 fix(knowledge): case-insensitive scheme checks for fileUrl waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/14bfcb7228d82a24dcd7c43cd390b2a2ca2dbe51
21a93a5 fix(mcp): annotate undici/DOM type-bridge double-casts in pinned-fetch waleedlatif1 May 17, 2026 https://github.com/simstudioai/sim/pull/4639/commits/21a93a58f824a0a30ded5901abd580f062ffcfec
Clear filters https://github.com/simstudioai/sim/pull/4639/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4639/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4639/files
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-45a8c5aee9a31e6a3052271a939826761ef626138cada2f4003fa67d5ca83ad6
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-2a74d2840671adc54823e635e962c3abed825ebada665629856997e1f2de90ea
utils.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-a23789193b4fafc6235ea44175e087730e9d3e974d6dc90432339cbe175f5c63
utils.ts https://github.com/simstudioai/sim/pull/4639/files#diff-4e38c10488e45626725c5de83295f593999a8b6c672fb4915c9a7ae356b8c8f8
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-9ea203a2aea391eeb3cbbac33ee273569ab505edad56b17dc4c33781754073e0
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-e2ac95dbaf98e6dec91737ebacf4371181fdf3d00dbb31107dbd382887c1a4e2
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-0cedffc8fb190ded9fe6b1a7bbbbb3c738d179fb1fc298a2112ff709928ee5c5
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-f9f93a655ebfa74f97e6bb9ca225b6f9d900827b6dc4396197d3228fb2e3d0aa
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-bc834c30c5734dbb55d99e516581f881dae88d7a59ea3b325a07149af52c6d25
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-c17c6c2db02c547d29b44e4d9889ee09f2c27c1de2952ee2f02de2de8023725b
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-deeaf3640f217f8dd02f81bb83519d23c1168e705272da558aedb43efb9c20d3
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-7c23babff2ac4eb73a0dd1c89091326701fe4fb1d0f6da081bc67386aeb7eec6
route.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-c97022e0faf6988829440b77efff2b483430011d1263e69453486949e50b3ebf
route.ts https://github.com/simstudioai/sim/pull/4639/files#diff-53e27f9e1361ba22f18fe22e89d21e3b51880fd7bb1bac3a7d0b2327f1c441da
email-auth.tsx https://github.com/simstudioai/sim/pull/4639/files#diff-18cbcbfcf5c37df7a7667f6be5e73bdfa9be36f55c44acbabff1d3aec82bc764
index.ts https://github.com/simstudioai/sim/pull/4639/files#diff-b246ce835df0ae835e1669613f5cb11e2c2e7ae99a2bcd861ee283d075ce0d61
form.tsx https://github.com/simstudioai/sim/pull/4639/files#diff-408b9aff34cec2137881d1d57911ea5c5a8577afafc9a4efe9e248ab0ce59403
forms.ts https://github.com/simstudioai/sim/pull/4639/files#diff-a013678db9817ddd0de5b255ad4ebb12acc51c8292b4efc14aeafb3a8ace31c4
forms.ts https://github.com/simstudioai/sim/pull/4639/files#diff-f68c30b1df291b079217c8dfe10bb0b692cc85c4b02d210968a0a1684282f9bc
documents.ts https://github.com/simstudioai/sim/pull/4639/files#diff-5fc1dd43e7e48f04aac58010b417d279c66b714c91f3960831d5276725495645
shared.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-7e3f7f1b796abcb858670866e6ef0264453585b0ba4331565db93504ef965ff8
shared.ts https://github.com/simstudioai/sim/pull/4639/files#diff-399e5a426c518769ab246287c61ca3ec750cb649403fbcc208b845440e8fdb9b
otp.ts https://github.com/simstudioai/sim/pull/4639/files#diff-01e8b7bcdb38e55e7190dee29cc6b722cdb479541a2cc02ce34139f55de01270
document-processor.ts https://github.com/simstudioai/sim/pull/4639/files#diff-caef18c7f5680f8ad0ec1e40b90e7635fe8f182b55d4fd20ef78fbe881f11205
service.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
service.ts https://github.com/simstudioai/sim/pull/4639/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
client.ts https://github.com/simstudioai/sim/pull/4639/files#diff-25cb24353597fac644145b37622d21ec7315282c29ccb1c4275f3ccb46441e1a
connection-manager.ts https://github.com/simstudioai/sim/pull/4639/files#diff-c4c5382013f44bc01eced63f50ecfcb606b8671498f14bb3e27467c1a5b632a1
domain-check.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-c3b6f6da4482a0e907673b6a0ad0d3eeab10c842e166a4c8181abee0f29198c0
domain-check.ts https://github.com/simstudioai/sim/pull/4639/files#diff-58bd7213609870689904920cd34776c761a43f28c35b7672a1925630fcb8676b
pinned-fetch.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-eb3b541d290de33fb3e61f5b074e2cfdb26cfd7a770a0ce1566316334a5ffec9
pinned-fetch.ts https://github.com/simstudioai/sim/pull/4639/files#diff-762eddc0923a0e087da8b1ddba48178609b8d41572e63b65e0cc2d027e79648c
service.ts https://github.com/simstudioai/sim/pull/4639/files#diff-19f6b7bbc0682d9438560d27d332499a5f8e1e4d1bf8aeb68dde6f2431137355
types.ts https://github.com/simstudioai/sim/pull/4639/files#diff-e2500ed2ccd0ca3bc978e658046d3908d959b18e02308756df87eb46e311df44
package.json https://github.com/simstudioai/sim/pull/4639/files#diff-43a1bb37ce68ac536b0a4ed9e973d9d52da3975d74b37865f591bb37e191be64
utils.server.ts https://github.com/simstudioai/sim/pull/4639/files#diff-9e8cf7bce7da1d94a302bf3f8f1c11a187c0bcbba08c5e9ded279b66fef5c415
utils.test.ts https://github.com/simstudioai/sim/pull/4639/files#diff-4fc9028961014b77986c725cf7788d973a00f86bab8c151c61755e30cefa9ebe
utils.ts https://github.com/simstudioai/sim/pull/4639/files#diff-3958a62932d77676d42afc1c3b446499dabc0d60ac57e5c1d6a94b6ee2bea76c
update_alert_rule.ts https://github.com/simstudioai/sim/pull/4639/files#diff-b4e689d06d5cc96b49d539dd16868353731361f46d826ecadb5d548481f4b7be
update_dashboard.ts https://github.com/simstudioai/sim/pull/4639/files#diff-6014947f9c6b23cc3af2ffcc99f0ed16c7ab06cb252ca0777b5281dd8847e385
bun.lock https://github.com/simstudioai/sim/pull/4639/files#diff-bfd0ef82a01108fa1e836c2500b98b7de8a92bb1ae352a8efcbd9d6ffcaabd60
check-api-validation-contracts.ts https://github.com/simstudioai/sim/pull/4639/files#diff-48ae6a4d0c1f820d5b644522d25742bb29af758bc8350f1a3cf3f8afa0bd00b0
apps/sim/app/api/chat/[identifier]/otp/route.tshttps://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
View file https://github.com/simstudioai/sim/blob/21a93a58f824a0a30ded5901abd580f062ffcfec/apps/sim/app/api/chat/%5Bidentifier%5D/otp/route.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/4639/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
https://github.com/simstudioai/sim/pull/4639/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
Please reload this pagehttps://github.com/simstudioai/sim/pull/4639/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4639/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.