Skip to main content

Khi GitHub Bị Tấn Công: Câu Chuyện Về PolinRider Supply Chain Attack

· 6 min read
Đàm Trọng An
DevOps Engineer @ LG CNS Viet Nam

Tài khoản GitHub của tôi và một đồng nghiệp vừa bị compromise bởi một cuộc tấn công supply chain tinh vi. Đây là những gì đã xảy ra, cách nó hoạt động, và cách bạn có thể tự bảo vệ mình.


🇻🇳 Tiếng Việt

Chuyện gì đã xảy ra?

Tài khoản GitHub của tôi và một đồng nghiệp đã bị compromise trong một cuộc tấn công supply chain đang diễn ra có tên PolinRider. Cuộc tấn công này được cho là đến từ nhóm DPRK (Triều Tiên), liên quan đến nhóm hacker khét tiếng Lazarus Group.

Theo một số nguồn khác, đây có thể là công của TeamPCP — nhóm đứng sau vụ hack npm Shai Hulud — tận dụng một VS Code extension bị nhiễm mã độc để xâm nhập GitHub và rò rỉ khoảng 3.800 repo nội bộ.

Điều đáng sợ nhất? Không có gì bất thường trong account login history cả.


Mã độc hoạt động như thế nào?

Vector lây nhiễm ban đầu:

  • Cài npm package độc hại từ registry
  • Cài VS Code extension độc hại trên máy local của developer

Hai package độc đã được xác nhận:

  • tailwind-mainanimation
  • tailwind-autoanimation

Sau khi lây nhiễm thành công, mã độc sẽ:

① Đánh cắp credentials trên máy local

  • GitHub token & Personal Access Token
  • SSH private keys
  • Browser sessions (cookies, saved passwords)
  • AWS / GCP credentials
  • Crypto wallet keys

② Inject mã JS obfuscated vào cuối các file config trong project:

postcss.config.mjs
tailwind.config.js
eslint.config.mjs
next.config.mjs
babel.config.js
App.js / app.js

③ Tạo file temp_auto_push.bat (trên Windows) để âm thầm force-push commit độc lên repo — giữ nguyên author + timestamp gốc, nên nhìn vào git history sẽ không thấy gì bất thường.


Phạm vi tấn công

Tại thời điểm được báo cáo:

  • 675 repositories bị ảnh hưởng
  • 352 owners (tài khoản GitHub) bị compromise

Làm sao để kiểm tra bạn có bị ảnh hưởng không?

1. Kiểm tra file config có bị inject code lạ không:

# Tìm dấu hiệu mã độc phổ biến trong file config
grep -rn "eval(" postcss.config.mjs tailwind.config.js eslint.config.mjs next.config.mjs 2>/dev/null
grep -rn "Buffer.from" postcss.config.mjs tailwind.config.js 2>/dev/null
grep -rn "atob\|btoa\|fromCharCode" postcss.config.mjs tailwind.config.js 2>/dev/null

# Tìm file bat đáng ngờ
find . -name "temp_auto_push.bat" 2>/dev/null

2. Kiểm tra git log có commit bất thường:

# Xem toàn bộ commit history kể cả force-push
git log --all --oneline
git reflog

3. Kiểm tra authorized apps và sessions trên GitHub:

  • GitHub → Settings → Applications → Authorized OAuth Apps
  • GitHub → Settings → Sessions → kiểm tra session lạ

Cách xử lý nếu bị compromise

  1. Revoke tất cả GitHub tokens ngay lập tức

    Settings → Developer settings → Personal access tokens → Revoke all

  2. Xóa và tạo lại SSH keys

    # Tạo key mới
    ssh-keygen -t ed25519 -C "[email protected]"
    # Thêm public key mới lên GitHub Settings → SSH keys
  3. Bật 2FA (dùng authenticator app như Authy hoặc Google Authenticator — không dùng SMS)

  4. Quét máy local bằng antivirus / endpoint detection tool

  5. Kiểm tra và revert các commit bất thường trong repo

  6. Đổi credentials các service liên quan: AWS, GCP, npm, Docker Hub, v.v.

  7. Báo cáo với GitHub: [email protected]


Bài học rút ra

"Bạn không cần click vào link phishing. Chỉ cần cài một package sai tên là đủ."

  • Không cài npm package / VS Code extension từ nguồn không rõ ràng
  • Audit định kỳ danh sách package và extension đang cài
  • Chạy npm audit thường xuyên trước khi commit
  • Không lưu credentials dạng plain text trên máy local — dùng secret manager
  • Bật 2FA cho tất cả tài khoản quan trọng
  • Áp dụng principle of least privilege cho mọi token — chỉ cấp quyền tối thiểu cần thiết
  • Giám sát git log thường xuyêngit reflog có thể tiết lộ force-push ẩn


🇬🇧 English

What Happened?

My GitHub account — along with a colleague's — was compromised in an ongoing supply chain attack known as PolinRider, attributed to DPRK (North Korea) and the Lazarus Group.

According to other sources, this may also be the work of TeamPCP — the group behind the Shai Hulud npm hack — using a malicious VS Code extension to breach GitHub and leak approximately 3,800 private repositories.

The scariest part? There was absolutely nothing unusual in the account login history.


How the Malware Works

Initial infection vectors:

  • Installing a malicious npm package from the registry
  • Installing a malicious VS Code extension on the developer's local machine

Two confirmed malicious packages:

  • tailwind-mainanimation
  • tailwind-autoanimation

Once infected, the malware:

① Steals local credentials

  • GitHub tokens & Personal Access Tokens
  • SSH private keys
  • Browser sessions (cookies, saved passwords)
  • AWS / GCP credentials
  • Crypto wallet keys

② Injects obfuscated JavaScript at the end of config files in your projects:

postcss.config.mjs
tailwind.config.js
eslint.config.mjs
next.config.mjs
babel.config.js
App.js / app.js

③ Creates temp_auto_push.bat (on Windows) to silently force-push malicious commits to your repositories — preserving the original author and timestamp so git history appears completely normal.


Attack Scale

At the time of reporting:

  • 675 repositories affected
  • 352 owners (GitHub accounts) compromised

How to Check if You're Affected

1. Inspect config files for injected code:

# Look for common malware patterns in config files
grep -rn "eval(" postcss.config.mjs tailwind.config.js eslint.config.mjs next.config.mjs 2>/dev/null
grep -rn "Buffer.from" postcss.config.mjs tailwind.config.js 2>/dev/null
grep -rn "atob\|btoa\|fromCharCode" postcss.config.mjs tailwind.config.js 2>/dev/null

# Search for suspicious batch file
find . -name "temp_auto_push.bat" 2>/dev/null

2. Review git history for suspicious commits:

git log --all --oneline
git reflog

3. Review GitHub authorized apps and active sessions:

  • GitHub → Settings → Applications → Authorized OAuth Apps
  • GitHub → Settings → Sessions

Remediation Steps

  1. Revoke all GitHub tokens immediately

    Settings → Developer settings → Personal access tokens → Revoke all

  2. Delete and regenerate SSH keys

    ssh-keygen -t ed25519 -C "[email protected]"
    # Add the new public key to GitHub Settings → SSH keys
  3. Enable 2FA using an authenticator app (Authy, Google Authenticator) — not SMS

  4. Scan your local machine with antivirus / endpoint detection tools

  5. Review and revert any suspicious commits in your repositories

  6. Rotate credentials for all linked services: AWS, GCP, npm, Docker Hub, etc.

  7. Report to GitHub: [email protected]


Key Takeaways

"You don't need to click a phishing link. Installing one wrongly named package is enough."

  • Never install npm packages or VS Code extensions from unverified sources
  • Regularly audit your installed packages and extensions
  • Run npm audit frequently before committing code
  • Never store credentials as plain text on your local machine — use a secrets manager
  • Enable 2FA on all important accounts
  • Apply the principle of least privilege for all tokens
  • Monitor your git log regularlygit reflog can reveal hidden force-pushes

References