Skip to content

fix(vcs): reject symlinked component checkout paths - #23206

Open
nijel wants to merge 8 commits into
mainfrom
review/oss-critical-y9nu65sp
Open

nijel wants to merge 8 commits into
mainfrom
review/oss-critical-y9nu65sp

Conversation

@nijel

@nijel nijel commented Nov 29, 2026

Copy link
Copy Markdown
Member

Keep component storage bound to its lexical VCS path and prevent repository content from aliasing another checkout or managed metadata.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.

@nijel nijel added this to the 2026.12 milestone Nov 29, 2026
@nijel nijel self-assigned this Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T20:48:45.461110Z 5045827 New commits
🔒 Security Review ✅ Completed 2026-11-29T16:50:44.631351Z 5812474 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread weblate/trans/mixins.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb5dcc3f9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/trans/mixins.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2de09d8d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/trans/models/category.py Resolved
@nijel
nijel enabled auto-merge (squash) November 29, 2026 18:08
@nijel
nijel force-pushed the review/oss-critical-y9nu65sp branch from 45c2ab4 to b154acc Compare November 29, 2026 18:54

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b154accd55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/trans/mixins.py
# Symlinks below the VCS directory can only come from repository
# content and would alias the storage of another object.
msg = f"Object path contains a symbolic link: {path}"
raise RepositoryPathError(msg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Translate unsafe paths before entering API checkout cleanup

When an API request creates a remote component whose destination is a stale symlink within VCS storage, this exception still produces HTTP 500 instead of a slug validation error. Unlike the previously reported form-validation paths, ComponentSerializer.validate() enters cleanup_remote_checkout_on_error(instance) before calling model validation; that context manager accesses component.repository, whose construction evaluates full_path before reaching its yield or exception handler. Consequently, neither of the new model-validation catches runs. Translate RepositoryPathError at this earlier API boundary, or validate the destination before constructing the repository.

Useful? React with 👍 / 👎.

@nijel
nijel force-pushed the review/oss-critical-y9nu65sp branch from b154acc to 46a29d8 Compare November 29, 2026 19:03

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46a29d864f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/trans/mixins.py
# Symlinks below the VCS directory can only come from repository
# content and would alias the storage of another object.
msg = f"Object path contains a symbolic link: {path}"
raise RepositoryPathError(msg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Translate rejected checkout paths in upload creation flows

When a document or ZIP upload uses a component slug pointing to a stale symlink within VCS storage, this exception still produces HTTP 500 instead of a slug validation error. Both create_component_from_doc() and create_component_from_zip() evaluate fake.full_path before model validation. The API explicitly skips cleanup_remote_checkout_on_error() for uploads, and neither create_uploaded_repository() nor the UI's CreateFromDoc.form_valid() and CreateFromZip.form_valid() translates RepositoryPathError. Validate the destination or translate the exception at the shared upload boundary so these creation flows reject the path cleanly too.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="weblate/api/serializers.py">

<violation number="1" location="weblate/api/serializers.py:2648">
P3: This validation message is a plain string, while the same message is wrapped in `gettext()` in `component.py` and the other shared messages in this file use `gettext_lazy`. Wrap it so API responses reuse the translated UI message.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

repository = component.repository
except RepositoryPathError as error:
raise serializers.ValidationError(
{"slug": "Repository path for this component is not valid."}

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.

P3: This validation message is a plain string, while the same message is wrapped in gettext() in component.py and the other shared messages in this file use gettext_lazy. Wrap it so API responses reuse the translated UI message.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At weblate/api/serializers.py, line 2648:

<comment>This validation message is a plain string, while the same message is wrapped in `gettext()` in `component.py` and the other shared messages in this file use `gettext_lazy`. Wrap it so API responses reuse the translated UI message.</comment>

<file context>
@@ -2638,9 +2639,15 @@ class ComponentSerializer(RemovableSerializer[Component]):
+            repository = component.repository
+        except RepositoryPathError as error:
+            raise serializers.ValidationError(
+                {"slug": "Repository path for this component is not valid."}
+            ) from error
+        with repository.lock.hold_before_recovery():
</file context>
Suggested change
{"slug": "Repository path for this component is not valid."}
{
"slug": gettext_lazy(
"Repository path for this component is not valid."
)
}

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71477b7365

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread weblate/trans/mixins.py
# Symlinks below the VCS directory can only come from repository
# content and would alias the storage of another object.
msg = f"Object path contains a symbolic link: {path}"
raise RepositoryPathError(msg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate checkout paths when duplicating components through the API

When an API creation request uses from_component without repo and its destination slug points to a stale symlink within VCS storage, this exception still produces HTTP 500. That flow skips both checkout cleanup contexts and uses validate_local_from_component_instance(), which calls only clean_model_settings() and validates language settings against the source component; neither validates the destination path. Validation therefore succeeds, but Component._save_component() subsequently calls refresh_linked_component() and raises the uncaught RepositoryPathError. Validate and translate the destination path error during this creation flow too, so the API returns a slug validation error.

Useful? React with 👍 / 👎.

Keep component storage bound to its lexical VCS path and prevent repository content from aliasing another checkout or managed metadata.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.
Convert symlinked category storage paths into a field validation error so category forms reject them cleanly.
Component creation and rename can encounter a symlinked repository path. Convert the path boundary error into a field validation error so requests fail cleanly.
Convert repository path boundary failures during category rename validation into a slug field error. Add coverage for an existing category moved onto a symlink.
Convert repository path failures from model settings validation to a slug error, matching the existing repository-settings path and CI regression.

Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.
Translate repository path failures raised while entering remote-checkout cleanup into a slug validation error, with API coverage for a stale symlink destination.

Discovered by Anthropic’s OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.
Report stale symlink destinations as slug validation errors in API and web upload creation before repository cleanup is tracked. Cover document and ZIP uploads in both flows.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.
Validate destination checkout paths before copying a component through the API, where local-source validation skips the model path check. Report a slug error and cover stale symlink destinations.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-Y9NU65SP.
@nijel
nijel force-pushed the review/oss-critical-y9nu65sp branch from 71477b7 to 5045827 Compare November 29, 2026 20:47
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
15885 1 15884 913
View the top 1 failed test(s) by shortest run time
weblate.api.tests.ComponentCheckoutAPITest::test_uploaded_component_rejects_symlinked_destination
Stack Traces | 0.487s run time
self = <weblate.api.tests.ComponentCheckoutAPITest testMethod=test_uploaded_component_rejects_symlinked_destination>

    def test_uploaded_component_rejects_symlinked_destination(self) -> None:
        for upload_field, fixture, file_format in (
            ("docfile", TEST_DOC, "html"),
            ("zipfile", TEST_ZIP, "po"),
        ):
            with self.subTest(upload_field=upload_field):
                slug = f"symlinked-{upload_field}"
                path = Path(self.project.full_path, slug)
                path.symlink_to(self.component.full_path, target_is_directory=True)
                with open(fixture, "rb") as handle:
                    response = self.do_request(
                        "api:project-components",
                        self.project_kwargs,
                        method="post",
                        code=400,
                        superuser=True,
                        request={
                            upload_field: handle,
                            "name": "Symlinked component",
                            "slug": slug,
                            "file_format": file_format,
                            "new_lang": "none",
                        },
                    )
>               self.assertEqual(response.data["errors"][0]["attr"], "slug")
E               AssertionError: 'filemask' != 'slug'
E               - filemask
E               + slug

weblate/api/tests.py:10834: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

This branch has not been deployed

No deployments
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