Logo Dependency Supply Chain Security

Dependency Supply Chain Security

Tổ chức
wpultimatesecurity
dependency-supply-chain-security

Dùng khi plugin hoặc giao diện đóng gói thư viện PHP hoặc JavaScript của bên thứ ba, tải tài nguyên từ CDN, tải hoặc thực thi mã trong lúc chạy, quản lý phần phụ thuộc bằng Composer hoặc chuẩn bị tệp zip để phân phối. Bao gồm ưu tiên tải tài nguyên bằng handle có sẵn trong lõi, kiểm tra phần phụ thuộc bằng composer audit, cố định phiên bản trong tệp lock, giữ artifact phân phối sạch bằng export-ignore, thêm Subresource Integrity cho tài nguyên CDN qua script_loader_tag, và từ chối dùng eval() cũng như các kiểu include từ xa. Ngăn xâm phạm chuỗi cung ứng qua mã bên thứ ba lỗi thời, chưa được kiểm tra hoặc tải từ xa.

Add to TypingMind

Tổng quan

Nhà phát hànhwpultimatesecurity
Kho mãWordPress-Security-Skills
Tên kỹ năngdependency-supply-chain-security
Sao
54
Bản fork
3
Tệp đi kèm
3
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được wpultimatesecurity công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Dependency Supply Chain Security trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/dependency-supply-chain-security
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wpultimatesecurity/WordPress-Security-Skills.git /tmp/WordPress-Security-Skills
mkdir -p .claude/skills
cp -r /tmp/WordPress-Security-Skills/skills/dependency-supply-chain-security .claude/skills/dependency-supply-chain-security
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Dependency Supply Chain Security trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Dependency Supply Chain Security ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Dependency Supply Chain Security với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Dependency & supply-chain security

When to use this skill

Use this skill whenever code consumes third-party code or assets:

  • Adding a Composer package, or vendoring a library copy into vendor/ or assets/lib/.
  • Enqueueing a script or stylesheet whose src is a full https:// CDN URL.
  • Loading PHP at runtime from the network, including "remote updater" patterns.
  • Preparing the distributable zip and deciding what ships inside vendor/.
  • Merging a snippet taken from Stack Overflow, a blog post, or an AI answer.

Do not reach for this skill for flaws in first-party code: use the output-escaping skill for XSS in your own markup, the capability-permission-checks skill for authorization, and the cron-background-job-security skill for cron callbacks.

A plugin is only as secure as the oldest library inside it. A large share of WordPress plugin CVEs are vulnerable bundled dependencies or compromised third-party code loaded at runtime, not bugs in the plugin's own logic.

Related: see the http-api-ssrf-prevention skill for validating URLs you fetch data from, the filesystem-security skill for confining local includes, and the secure-plugin-development skill for overall plugin hardening.

Core principles (and why they matter)

  1. Prefer core over bundling. WordPress registers jQuery, Underscore, Backbone, media libraries, and the block-editor React build under documented handles. wp_enqueue_script() the core handle instead of shipping your own copy: bundled duplicates drift out of date and conflict with other plugins and themes that use the core version. Core patches its bundled libraries; your vendored copy of the same library gets no patches.
  2. Vet before adding. Confirm the project shipped a release in the last ~12 months, scan its CVE history, and check the license is compatible with GPL where required. composer audit (Composer 2.4+) checks installed packages against the Packagist advisory database; the roave/security-advisories dev dependency refuses installs of known-vulnerable versions outright.
  3. Lock and pin. Commit composer.lock and build with composer install, never composer update. Avoid minimum-stability: dev and unbounded constraints like dev-main: they make builds unreproducible and unauditable, so a compromise upstream is indistinguishable from your own release.
  4. Ship a minimal artifact. Distributable zips must not contain dev dependencies, tests, CI configs, or demo data. .gitattributes export-ignore lines keep them out of git archive / composer archive builds, so attackers cannot read your tests to map untested code paths.
  5. Never load code from the network at runtime. eval(), string assert(), create_function() (removed in PHP 8), the preg /e modifier (removed in PHP 7), or include/require of a fetched file, including wp_remote_get() bodies and phar:// deserialization tricks, is RCE by design. Updates ship through an update channel; fetched payloads are not an update channel.
  6. Integrity-check front-end assets you do not host. Self-host when possible. If a CDN is required, pin an exact version URL and add Subresource Integrity (integrity + crossorigin attributes) via the script_loader_tag / style_loader_tag filters. Never enqueue a URL whose content can change, such as latest.js.
  7. Keep update latency low for what you ship. Do not ship code that blocks the auto-updates users rely on (auto_update_plugin, auto_update_theme, WP_AUTO_UPDATE_CORE, AUTOMATIC_UPDATER_DISABLED). Guard your own PHP and WordPress minimums with version_compare() and release patched builds fast when a bundled dependency announces a CVE.
  8. Treat pasted snippets as untrusted dependencies. Rewrite them against current WordPress APIs and check for removed functions (mysql_*, create_function()) before merging. A snippet copied from 2011 carries the threat model of 2011.

Step-by-step implementation

  1. Before vendoring, check whether WordPress core already registers the asset. The wp_register_script() documentation lists the default handles (jquery, jquery-ui-*, underscore, backbone, wp-api, and more). Enqueue the handle; do not print your own copy of the same file.

  2. Vet each new dependency before the first composer require:

    • Last tagged release within roughly the last 12 months.
    • No open high-severity advisories: run composer audit after adding.
    • License compatible with the plugin's distribution (GPL-compatible for WordPress.org hosting).
    • For non-Composer front-end libraries, check advisories with OWASP Dependency-Check or the vendor's security page.
  3. Configure Composer for reproducible builds and commit the lock file:

    json
    {
        "name": "acme/my-plugin",
        "minimum-stability": "stable",
        "require": {
            "php": ">=7.4"
        },
        "require-dev": {
            "roave/security-advisories": "dev-latest"
        },
        "config": {
            "sort-packages": true
        }
    }

    Build with composer install --no-dev --optimize-autoloader. Only composer update intentionally bumps the lock file, and the diff gets reviewed like any other code change.

  4. Keep tests, CI configs, and demo data out of the shipped zip via .gitattributes:

    /.github            export-ignore
    /tests              export-ignore
    /demo               export-ignore
    /phpcs.xml.dist     export-ignore
    /phpunit.xml.dist   export-ignore
  5. Enforce your minimums at load time with version_compare() and refuse to run on stacks below them (see the reference file for the guard).

  6. For CDN assets: self-host if possible. Otherwise pin an exact version URL, store an integrity hash per asset, and add integrity + crossorigin through the script_loader_tag / style_loader_tag filters (full example in the reference file).

  7. Ship no auto-update blockers. Never distribute add_filter( 'auto_update_plugin', '__return_false' ); or a define( 'AUTOMATIC_UPDATER_DISABLED', true ); inside plugin code. If you must influence updates, filter only your own plugin:

    php
    // Keep this plugin on the auto-update train; never silence the whole site.
    add_filter( 'auto_update_plugin', 'my_plugin_auto_update_self', 10, 2 );
    function my_plugin_auto_update_self( $update, $item ) {
        if ( isset( $item->slug ) && 'my-plugin' === $item->slug ) {
            return true;
        }
        return $update;
    }
  8. Grep the codebase before every release for runtime code loading: eval(, assert(, create_function(, preg_replace( with /e, include/require fed by wp_remote_get(), and phar:// stream usage.

  9. Rewrite pasted snippets against current APIs before merging. Anything calling mysql_* or create_function() was written for PHP that no longer runs your code.

Supporting references

ReferenceLoad when
Dependency & supply-chain cheatsheetChoosing the applicable WordPress API or control for dependency and supply-chain security.
Dependency & supply-chain checklistBefore final verification of the dependency & supply-chain controls.
Secure dependency managementImplementing version-gated dependency loading, core asset reuse, pinned CDN assets, and confined local includes.

Common AI mistakes / anti-patterns

Mistake 1 - Vendoring a stale copy of a library core already ships

php
// ❌ Insecure: bundles an old PHPMailer 5.x copy "because it worked".
// Old 5.x releases carry known remote-command-execution CVEs, and this copy
// never receives patches. Core's copy does.
require_once __DIR__ . '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
php
// ✅ Secure: wp_mail() uses the PHPMailer version core ships and patches.
wp_mail( $to, $subject, $message, $headers );

Mistake 2 - CDN script with no version pin and no integrity

php
// ❌ Insecure: "chart.js" can change content at any time; the CDN operator
// (or anyone compromising it) controls the code that runs on every site.
wp_enqueue_script( 'my-charts', 'https://cdn.example.com/chart.js', array(), null );
php
// ✅ Secure: exact version URL + Subresource Integrity, or self-host the file.
wp_enqueue_script(
    'my-charts',
    'https://cdn.jsdelivr.net/npm/chart.js@4.1.2/dist/chart.umd.min.js',
    array(),
    '4.1.2', // Matches the version pinned in the URL path.
    true     // Load in the footer.
);
// integrity/crossorigin attributes are added in the script_loader_tag filter.

Mistake 3 - Runtime updater that fetches and executes code

php
// ❌ Insecure: RCE by design, and the plugin bricks itself when the host dies.
// $response = wp_remote_get( 'https://example.com/updater.php' );
// $body     = wp_remote_retrieve_body( $response );
// eval( $body );        // executes whatever the remote server returns
// include $tmp_path;    // same result if $tmp_path holds the fetched payload
php
// ✅ Secure: updates arrive through the WordPress.org update channel, or a
// signed self-hosted channel. Metadata travels over the network; code does not.
// Plugins on WordPress.org need no custom updater code at all.

Mistake 4 - Committing vendor/ with dev dependencies and CI configs

php
// ❌ Insecure: the distributable zip ships phpunit, phpcs configs, and test
// fixtures. Attackers read tests to map code paths nothing verifies.
// Built with: composer update (whatever was newest that Tuesday).
php
// ✅ Secure: export-ignore keeps dev trees out of archives; builds are pinned.
// .gitattributes:
//   /tests          export-ignore
//   /.github        export-ignore
// Build command:
//   composer install --no-dev --optimize-autoloader

Mistake 5 - minimum-stability: dev plus unbounded constraints

json
// ❌ Insecure: every build resolves differently; you cannot audit what ships.
{
    "minimum-stability": "dev",
    "require": { "monolog/monolog": "dev-main" }
}
json
// ✅ Secure: stable channel, bounded constraints, committed lock file.
{
    "minimum-stability": "stable",
    "require": { "monolog/monolog": "^3.0" }
}

Mistake 6 - Shipping removed dynamic-code constructs

php
// ❌ Insecure: fatals on PHP 8 (create_function removed) and on PHP 7 (/e
// modifier removed). Both execute strings as code, which is the point.
// $double  = create_function( '$a', 'return $a * 2;' );
// $bold    = preg_replace( '/<b>(.*?)<\/b>/e', 'strtoupper("$1")', $html );
php
// ✅ Secure: closures and callbacks; no string-as-code anywhere.
$double = function ( $a ) {
    return $a * 2;
};
$bold = preg_replace_callback(
    '/<b>(.*?)<\/b>/',
    function ( $m ) {
        return strtoupper( $m[1] );
    },
    $html
);

Mistake 7 - CI that hands release secrets to untrusted code

yaml
# ❌ Insecure: pull_request_target runs with repository secrets and checks out
# the fork's code, so a pull request can read SVN_PASSWORD. Actions pinned to a
# moving tag can also change underneath the workflow.
on: pull_request_target
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: some-org/deploy-action@main
        env:
          SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
yaml
# ✅ Secure: untrusted PRs run without secrets; deploys run only on tags from
# the main repository, with least-privilege tokens and SHA-pinned actions.
on:
  push:
    tags: [ 'v*' ]
permissions:
  contents: read
jobs:
  deploy:
    if: github.repository == 'my-org/my-plugin'
    runs-on: ubuntu-latest
    environment: wordpress-org
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4.x
      - uses: some-org/deploy-action@<full-commit-sha>
        env:
          SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}

Also check custom update servers: updates must come over HTTPS from an endpoint you control, with the package verified (signature or checksum from a trusted channel) before install, and the release zip built from the tagged commit.

Correct code examples

A complete reference module covering core-handle-first enqueuing, pinned CDN assets with Subresource Integrity via the script_loader_tag filter, a version_compare() minimum-version gate, and a guarded local include confined to the plugin directory is in references/secure-dependency-management.php.

A before-adding / before-shipping checklist is in references/checklist.md, and a situation-to-practice lookup table is in references/cheatsheet.md.

Checklist

  • Core handles are used for assets WordPress registers (jquery, underscore, editor builds).
  • Every bundled dependency is maintained (release within ~12 months) and audited (composer audit).
  • roave/security-advisories is in require-dev for Composer projects.
  • composer.lock is committed; builds run composer install --no-dev.
  • minimum-stability is stable; no unbounded dev-* constraints.
  • .gitattributes export-ignore keeps tests, CI configs, and demo data out of the zip.
  • No eval(), string assert(), create_function(), preg /e, or remote include/require anywhere in shipped code.
  • CDN assets are self-hosted, or pinned to an exact version with integrity + crossorigin attributes.
  • No enqueued URL resolves to changeable content such as latest.js.
  • Shipped code contains no auto_update_plugin / auto_update_theme / AUTOMATIC_UPDATER_DISABLED blockers.
  • PHP and WordPress minimums are enforced with version_compare() before the plugin loads.
  • Pasted snippets were rewritten against current APIs before merging.
  • CI never runs untrusted pull-request code with secrets (pull_request_target + PR checkout, or workflow_run on fork artifacts).
  • Third-party GitHub Actions are pinned to full commit SHAs; workflow permissions are least-privilege; deploy secrets live in a protected environment.
  • Custom update endpoints use HTTPS and verify the package before install; release zips are built from the tagged commit.

Official references

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Dependency Supply Chain Security làm được gì?

Dùng khi plugin hoặc giao diện đóng gói thư viện PHP hoặc JavaScript của bên thứ ba, tải tài nguyên từ CDN, tải hoặc thực thi mã trong lúc chạy, quản lý phần phụ thuộc bằng Composer hoặc chuẩn bị tệp zip để phân phối. Bao gồm ưu tiên tải tài nguyên bằng handle có sẵn trong lõi, kiểm tra phần phụ thuộc bằng composer audit, cố định phiên bản trong tệp lock, giữ artifact phân phối sạch bằng export-ignore, thêm Subresource Integrity cho tài nguyên CDN qua script_loader_tag, và từ chối dùng eval() cũng như các kiểu include từ xa. Ngăn xâm phạm chuỗi cung ứng qua mã bên thứ ba lỗi thời, chưa được...

Vì sao nên dùng Dependency Supply Chain Security trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Dependency Supply Chain Security là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Dependency Supply Chain Security trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/dependency-supply-chain-security. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Dependency Supply Chain Security?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Dependency Supply Chain Security với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Dependency Supply Chain Security với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Dependency Supply Chain Security có miễn phí không?

Có. Kỹ năng này được wpultimatesecurity phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇