Skip to content

Commit 3157a3a

Browse files
committed
feat: release 1.4.0 - Runtime Security & Integrity Verification
Security Policy: - Add KSafeSecurityPolicy with IGNORE/WARN/BLOCK actions - Add root detection (Android) and jailbreak detection (iOS) - Add debugger, emulator, and debug build detection - Add preset policies: Default, Strict, WarnOnly Platform Integrity: - Add IntegrityChecker for server-side device verification - Android: Google Play Integrity API - iOS: Apple DeviceCheck API Compose: - Add UiSecurityViolation wrapper for Compose stability iOS: - Use real Keychain on Simulator (software-backed) - Remove MockKeychain in favor of actual Keychain APIs Testing: - Add KSafeSecurityPolicyTest, IntegrityCheckerTest - Add BiometricAuthorizationDurationTest, KSafeMemoryPolicyTest - Add ksafe-compose tests (KSafeComposeStateTest, etc.) Documentation: - Add threat model and security boundaries - Add compatibility matrix - Restructure README with Quickstart first
1 parent fadfcf9 commit 3157a3a

File tree

48 files changed

+3747
-668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3747
-668
lines changed

CHANGELOG.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,105 @@
22

33
All notable changes to KSafe will be documented in this file.
44

5+
## [1.4.0] - 2025-01-11
6+
7+
### Added
8+
9+
#### Runtime Security Policy
10+
- **New `KSafeSecurityPolicy`** for detecting runtime security threats
11+
- **Configurable actions** - `IGNORE`, `WARN`, or `BLOCK` for each security check:
12+
- `IGNORE` - No detection performed, no callback invoked
13+
- `WARN` - Detection runs, callback invoked, app continues normally
14+
- `BLOCK` - Detection runs, callback invoked, throws `SecurityViolationException`
15+
- **Preset policies** - `Default`, `Strict`, `WarnOnly` for common configurations
16+
```kotlin
17+
val ksafe = KSafe(
18+
context = context,
19+
securityPolicy = KSafeSecurityPolicy.Strict
20+
)
21+
```
22+
23+
#### Root & Jailbreak Detection
24+
- **Enhanced Android root detection**:
25+
- su binary paths (`/system/bin/su`, `/system/xbin/su`, etc.)
26+
- Magisk paths (`/sbin/.magisk`, `/data/adb/magisk`, etc.)
27+
- BusyBox installation paths
28+
- Xposed Framework (files + stack trace detection)
29+
- Root management apps (Magisk Manager, SuperSU, LSPosed, KingRoot, etc.)
30+
- Build tags (`test-keys`) and dangerous system properties
31+
- **iOS jailbreak detection**:
32+
- Cydia, Sileo, and other jailbreak app paths
33+
- System write access test (fails on non-jailbroken devices)
34+
- Common jailbreak tool paths (`/bin/bash`, `/usr/sbin/sshd`, etc.)
35+
- ⚠️ **Limitation**: Sophisticated root-hiding tools (Magisk DenyList, Shamiko, Zygisk) may bypass detection
36+
37+
#### Debugger & Emulator Detection
38+
- **Debugger detection** - Detect attached debuggers on all platforms
39+
- **Emulator detection** - Detect emulators/simulators (Android & iOS)
40+
- **Debug build detection** - Detect debug builds
41+
42+
#### Platform Integrity Verification
43+
- **New `IntegrityChecker`** class for server-side device verification
44+
- **Google Play Integrity** (Android) - Generates tokens for server verification
45+
- Requires Google Cloud project number
46+
- Graceful fallback on non-GMS devices (Huawei, Amazon Fire)
47+
- **Apple DeviceCheck** (iOS) - Generates tokens for server verification
48+
- No additional configuration needed
49+
- **JVM** - Returns `IntegrityResult.NotSupported`
50+
```kotlin
51+
// Android
52+
val checker = IntegrityChecker(context, cloudProjectNumber = 123456789L)
53+
54+
// iOS
55+
val checker = IntegrityChecker()
56+
57+
when (val result = checker.requestIntegrityToken(nonce)) {
58+
is IntegrityResult.Success -> sendToServer(result.token)
59+
is IntegrityResult.Error -> handleError(result.message)
60+
is IntegrityResult.NotSupported -> fallback()
61+
}
62+
```
63+
- ⚠️ **Important**: Tokens MUST be verified server-side. Client-side verification is insecure.
64+
65+
#### Compose Support
66+
- **New `UiSecurityViolation`** - Immutable wrapper for `SecurityViolation` ensuring Compose stability
67+
```kotlin
68+
@Immutable
69+
data class UiSecurityViolation(val violation: SecurityViolation)
70+
```
71+
- Allows `ImmutableList<UiSecurityViolation>` to skip unnecessary recompositions
72+
- Located in `ksafe-compose` module
73+
74+
### Added (Testing)
75+
- **Comprehensive test suite** for new security features:
76+
- `KSafeSecurityPolicyTest` - SecurityAction, SecurityViolation, presets
77+
- `IntegrityCheckerTest` - IntegrityResult sealed class behavior
78+
- `BiometricAuthorizationDurationTest` - Duration and scope patterns
79+
- `KSafeMemoryPolicyTest` - Memory policy enum
80+
- `JvmSecurityCheckerTest` - JVM-specific security behavior
81+
- **ksafe-compose module tests**:
82+
- `KSafeComposeStateTest` - Compose state integration tests
83+
- `KSafeMutableStateOfTest` - MutableState behavior tests
84+
- `AndroidKSafeMutableStateOfTest` - Android instrumented tests
85+
- `JvmKSafeMutableStateOfTest` - JVM-specific tests
86+
87+
### Changed
88+
- **iOS Simulator uses real Keychain** - Removed `MockKeychain` in favor of actual iOS Keychain APIs
89+
- Simulator: Software-backed Keychain
90+
- Real device: Hardware-backed Keychain (Secure Enclave)
91+
- Added threat model and security boundaries
92+
- Added compatibility matrix
93+
- Added GCM (Galois/Counter Mode) explanation
94+
- Added detailed Actions behavior documentation with examples
95+
- Added non-GMS device compatibility notes
96+
- Added root detection methods documentation
97+
98+
### Removed
99+
- **`MockKeychain.kt`** - iOS Simulator now uses real Keychain APIs instead of UserDefaults-based mock
100+
- **Irrelevant images** - Removed unnecessary publishing screenshots from repository
101+
102+
---
103+
5104
## [1.3.0] - 2025-12-31
6105

7106
### Added
@@ -28,8 +127,20 @@ All notable changes to KSafe will be documented in this file.
28127
- `clearBiometricAuth()` - Clear all cached authorizations
29128
- `clearBiometricAuth(scope)` - Clear only a specific scope
30129

130+
#### Configurable Encryption
131+
- **New `KSafeConfig` data class** for encryption customization
132+
- Configurable AES key size: 128-bit or 256-bit (default)
133+
```kotlin
134+
// Default (AES-256)
135+
val ksafe = KSafe(context)
136+
137+
// Custom key size (AES-128)
138+
val ksafe128 = KSafe(context, config = KSafeConfig(keySize = 128))
139+
```
140+
31141
### Changed
32142
- **iOS thread safety improvements** - Biometric callbacks now always execute on Main thread
143+
- **License consistency** - Fixed Maven POM metadata to use Apache-2.0 (matching repository)
33144

34145
---
35146

0 commit comments

Comments
 (0)