Skip to content

fix(vcs): verify TLS for Git provider API calls by default - #14802

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/vcs-tls-verify
Oct 22, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/vcs-tls-verify

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Git provider adapters disabled TLS certificate verification for every API request. The adapter now verifies certificates by default, so GitHub, GitLab, Gitea, Bitbucket, Origin and Entire API calls all check the server certificate, matching what OAuth2 token exchange and git clone/push already did.

  • packages/vcs: selfSigned defaults to false; adds setSelfSigned() / isSelfSigned() next to the existing setters so library consumers can opt out explicitly.
  • Appwrite exposes no opt-out. OAuth2 and git clone/push have always verified certificates, so a self-signed Gitea or GitLab host never worked end to end; an opt-out for API calls alone would not change that.

Test plan

  • packages/vcs/tests/AdapterTest.php: every adapter verifies by default and only accepts self-signed certificates after setSelfSigned(true) (fails on the old default)
  • tests/unit/Vcs/FactoryTest.php: every registered provider built by the factory verifies by default
  • bin/monorepo check vcs (Pint, PHPStan, Rector) and the vcs unit tier
  • Pint, PHPStan and Rector on the changed Appwrite files

Related: appwrite-labs/cloud#6666

Provider API requests skipped certificate verification for every adapter.
Verification is now on by default; self-hosted Gitea and GitLab installs
behind a private CA can opt out with _APP_VCS_GITEA_SELF_SIGNED or
_APP_VCS_GITLAB_SELF_SIGNED.
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high

📍 Findings outside the diff (1) — 🟠 1 high — defects on lines GitHub can't attach comments to

🟠 High — Git clone/push shell commands ignore selfSigned · Git.php:322–366 · file not in diff

// packages/vcs/src/Adapter/Git.php
322	    protected function cloneCommand(string $cloneUrl, string $version, string $versionType, string $directory, string $rootDirectory): Command
323	    {
324	        $rootDirectory = $this->normalizeRepositoryPath($rootDirectory);
325	        if ($rootDirectory === '') {
326	            $rootDirectory = '*';
327	        }
328	
329	        // A leading dash would reach git as an option instead of a ref; a tag
330	        // travels as refs/tags/<name>, so any name is safe there
331	        if ($versionType !== self::CLONE_TYPE_TAG && str_starts_with($version, '-')) {
332	            throw new InvalidArgumentException("Invalid clone version: {$version}");
333	        }

The new _APP_VCS_*_SELF_SIGNED flag only disables TLS verification in the adapter's HTTP client (Adapter::call()), while the actual code fetch runs as shell git commands: cloneCommand() in packages/vcs/src/Adapter/Git.php:322 builds plain git init/remote add/fetch/checkout chains with no http.sslVerify config, executed verbatim by the builds worker at src/Appwrite/Platform/Modules/Functions/Workers/Builds.php:313. For a self-signed or private-CA Gitea/GitLab host, git's default http.sslVerify=true rejects the certificate, so with the env var set to enabled the API calls succeed but the deployment build still fails at "Unable to clone code repository". The same applies to generatePushCommand() when pushing template branches back, so the opt-in does not achieve its stated purpose for the primary flow it exists for.


The change introduces an opt-in for self-signed TLS certificates on self-hosted Gitea/GitLab providers: two new env variables wired through .env, docker-compose.yml, app/config/variables.php, app/config/vcs.php, and the console compose generator, a default flip of selfSigned to false in the vcs package adapter, and Factory wiring that applies the flag per provider. The config layers are in sync across all four layers, and unit tests cover both the adapter default and the Factory env parsing. However, the opt-in is applied only to the adapter's HTTP client, leaving the two other outbound paths to self-hosted instances — the git clone/push shell commands and the OAuth2 token exchange — still verifying certificates, so the flag does not achieve its purpose end-to-end for the primary install/build flows.

Files Change
packages/vcs/src/Adapter.php Flips the selfSigned default from true to false on all VCS adapters
src/Appwrite/Vcs/Factory.php Reads the per-provider selfSigned env variable and applies it when building adapters
.env, docker-compose.yml, app/config/variables.php, app/config/vcs.php Add the two new _APP_VCS_*_SELF_SIGNED variables (default disabled) and per-provider selfSigned config entries
apps/console/.../composeData.ts Mirrors the new env entries into the console compose-generator output
packages/vcs/tests/AdapterTest.php, tests/unit/Vcs/FactoryTest.php Unit tests for the new adapter default and the Factory env parsing/cleanup

Reviewed commit: ec8e649

@appwrite

appwrite Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

New Console

Project ID: new-console

Sites (1)
Site Status Logs Preview QR
 New Console
new-console
Ready Ready View Logs Preview URL QR Code

Tip

Teams feature lets you group users with membership management and role permissions

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed API-call path now retains the HTTP client’s normal certificate verification defaults, and no additional actionable issue was found.

The VCS adapter now verifies TLS certificates by default, with an explicit setter for consumers who need to disable verification. Tests cover the default and opt-in state across adapter classes and Appwrite’s registered providers.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
packages/vcs/src/Adapter.php Defaulted TLS verification on and added public methods to configure and inspect the self-signed certificate option.
packages/vcs/tests/AdapterTest.php Added adapter-wide tests for the default TLS setting and explicit opt-in.
tests/unit/Vcs/FactoryTest.php Added coverage that Appwrite’s registered provider adapters verify certificates by default.

Reviewed d7bd966 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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.

🔵 Tier A · See the inline comments. Summary

Comment thread src/Appwrite/Vcs/Factory.php Resolved
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/vcs-tls-verify (after).

Metric Before After Change
🚀 Requests/sec 183.53 192.33 ⚪ +4.8%
⏱️ Latency P50 94.35 ms 89.65 ms ⚪ -5%
⏱️ Latency P95 227.15 ms 208.02 ms 🟢 -8.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.65 208.02 12,369 192.33 -19.13
Account 170.36 341.57 651 10.78 +11.32
TablesDB 86.5 162.22 6,727 107.33 -34.06
Storage 83.5 192.45 3,255 53.18 -9.71
Functions 124.94 243.74 1,736 29.17 -0.99

Top API waits (after)

API request Max wait (ms)
account.name.update 659.16
account.prefs.update 478.35
functions.variables.create 458.54
storage.buckets.create 454.4
tablesdb.rows.create 368.25

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@14802

commit: ec8e649

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

OAuth2 token exchange and git clone/push already verified certificates, so a
self-signed host never worked end to end and the opt-in only covered one of
three paths. Verify everywhere instead of extending the opt-out.
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

Good catch, thanks. OAuth2 token exchange and git clone/push have always verified certificates, so a self-signed Gitea or GitLab host never worked end to end, and the opt-in only covered one of the three paths. Rather than extend the opt-out to all three, d7bd966 drops the _APP_VCS_GITEA_SELF_SIGNED / _APP_VCS_GITLAB_SELF_SIGNED plumbing, so Appwrite now verifies certificates on every path. The adapter keeps setSelfSigned() as explicit library API only.

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit e5d66e2 into main Oct 22, 2026
42 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/vcs-tls-verify branch October 22, 2026 18:57
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
fix(vcs): verify TLS for Git provider API calls by default

(cherry picked from commit e5d66e2)
sarbojitrana pushed a commit to sarbojitrana/appwrite that referenced this pull request Nov 2, 2026
utopia-php/vcs 4.x accepts self-signed certificates on every provider API call by default.
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.

1 participant