T08 · Insecure Dependencies
- Location
references/cocoapods.md:8- Finding
Privileged CocoaPods Installation Through a Third-Party RubyGems Source
- Content
View full analysis
Vulnerability Details
File Location:
references/cocoapods.md, lines 8-13
Vulnerability Type: Supply-chain exposure during privileged system-wide package installation
Risk Level: HighVulnerable Code
bash gem sources -l gem sources --remove https://rubygems.org/ gem sources -a https://gems.ruby-china.com sudo gem update --system sudo gem install -n /usr/local/bin cocoapods # macOS > 10.11 pod setupTechnical Analysis
The installation procedure removes the official RubyGems registry and replaces it with a third-party mirror. It then updates RubyGems and installs CocoaPods system-wide using
sudo.Ruby gems can contain installation logic and executable components. If the configured mirror, its distribution infrastructure, or a package served through it is compromised, attacker-controlled package content may execute with root privileges during installation. The procedure does not pin the CocoaPods version, validate an artifact digest, verify a package signature, or otherwise establish that the downloaded package is identical to a reviewed release.
Removing the official source also changes package resolution globally for the affected RubyGems installation, potentially influencing later gem installations beyond the current Baidu SDK integration task.
Attack Path
- A developer or Agent follows the documented CocoaPods installation procedure.
- The official
rubygems.orgsource is removed from the local RubyGems configuration. - Package resolution is redirected to
gems.ruby-china.com. - An attacker compromises the mirror, its upstream synchronization process, or a package available through it.
- The developer runs
sudo gem update --systemorsudo gem install. - Malicious package installation logic executes with elevated privileges.
- The attacker can modify system-wide development tooling or access resources available to the root installation process.
Im
...[truncated 549 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not remove the official
https://rubygems.org/source. - Do not use
sudo gem update --systemas part of project setup. - Install a specifically reviewed CocoaPods version rather than an unconstrained latest release.
- Prefer a repository-local
Gemfileand committedGemfile.lock, executed throughbundle exec pod. - Use a user-scoped Ruby version manager or another non-root installation method.
- If an organizational mirror is required, retain a trusted upstream policy and verify mirror ownership, TLS configuration, package integrity, and synchronization controls.
- Validate package checksums or signatures where supported.
- Require explicit user confirmation before changing global package sources or performing privileged installation.
- Do not remove the official
