- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`ID: swift-security/trustkit-pinning
Language: Unknown
Severity: Error
Category: Security
CWE: 295
This rule detects improper or disabled certificate pinning when using TrustKit in iOS applications. Without strict pinning, attackers could intercept and manipulate network traffic through Man-in-the-Middle (MitM) attacks, compromising confidentiality and integrity of user data. To mitigate this, applications should enforce proper certificate pinning configurations in line with Apple guidelines.
import Foundation
import TrustKit
// --- NON-COMPLIANT EXAMPLE 1: Pinning is not enforced ---
// ruleid: trustkit_pinning_enforce_disabled
let trustKitConfigEnforceDisabled: [String: Any] = [
kTSKPinnedDomains: [
"www.datatheorem.com": [
kTSKEnforcePinning: false, // VULNERABILITY: Pinning is explicitly disabled.
kTSKIncludeSubdomains: true,
kTSKPublicKeyHashes: [
"someHash1",
"someHash2"
]
]
]
]
TrustKit.init(configuration: trustKitConfigEnforceDisabled)
// --- NON-COMPLIANT EXAMPLE 2: Subdomain pinning is disabled ---
// ruleid: trustkit_pinning_subdomain_disabled
let trustKitConfigSubdomainDisabled: [String: Any] = [
kTSKPinnedDomains: [
"example.com": [
kTSKEnforcePinning: true,
kTSKIncludeSubdomains: false, // VULNERABILITY: Subdomains are not pinned.
kTSKPublicKeyHashes: [
"anotherHash1",
"anotherHash2"
]
]
]
]
TrustKit.init(configuration: trustKitConfigSubdomainDisabled)
import Foundation
import TrustKit
// This file demonstrates the SECURE and COMPLIANT way to configure TrustKit.
// Define the TrustKit configuration dictionary.
let trustKitConfig: [String: Any] = [
kTSKPinnedDomains: [
"www.datatheorem.com": [
// COMPLIANT: Pinning is explicitly enforced. This is the most critical setting
// to prevent MitM attacks.
kTSKEnforcePinning: true,
// COMPLIANT: Pinning is also enforced for all subdomains, ensuring
// comprehensive security coverage for the entire domain.
kTSKIncludeSubdomains: true,
// Provide the valid Base64-encoded SHA-256 hashes of the public keys.
kTSKPublicKeyHashes: [
"khh4hgtv9b0z6yioj2l8f9d6h3j3b2b1j6g6f8d3d2c2b1a0", // Primary key
"jhh5igtv9b0z6yioj2l8f9d6h3j3b2b1j6g6f8d3d2c2b1a1" // Backup key
],
]
]
]
// Initialize TrustKit with the secure configuration.
// This should be done early in the app's lifecycle, e.g., in AppDelegate.
TrustKit.init(configuration: trustKitConfig)
print("TrustKit has been initialized with a SECURE pinning configuration.")