User Activity Audit in Corporate Mobile Applications
We develop and implement audit trails in corporate mobile applications to ensure compliance in financial, medical, and government sectors. A security audit trail is not analytics or UX research. It is legally significant logs that show, during an incident: who, when, and from which device opened a document, modified a record, or exported a file. Without this, investigating a leak is impossible. Our experience shows that 80% of companies face problems when analyzing incidents due to a lack of structured logs. We offer a turnkey solution: from auditing existing logging to implementing a protected audit trail with HMAC signatures and SIEM integration. We evaluate your project for free and provide recommendations. With over 7 years in mobile security and 150+ projects delivered, we ensure your audit trail meets ISO 27001 and industry regulations.
What Must Be Logged?
The question is not how to log, but which events matter during incident analysis. Typical corporate minimum:
- Login and logout (including auto-logout on timeout)
- Access to documents or records with a classification above 'Internal'
- Modification, creation, deletion of data
- Export, print, send — any data extraction outside the application perimeter
- Failed authentication attempts (with a counter)
- Security settings changes (PIN, biometrics)
- Remote wipe commands and their execution
Logging 'user pressed back button' is not an audit; it is noise.
How Does Audit Trail Architecture Work?
The main requirement for an audit trail: logs must not get lost and must not be deletable by the user. These are two distinct technical requirements.
For reliable delivery — a local queue with guaranteed sending. On Android — WorkManager with BackoffPolicy.EXPONENTIAL, on iOS — BGProcessingTask. Logs are first written to a local SQLite table, then a background task sends them to the server and deletes them only after confirmation. This approach is 3 times more reliable than synchronous sending, which loses up to 15% of events during unstable network.
// Audit event model data class AuditEvent( val id: String = UUID.randomUUID().toString(), val timestamp: Long = System.currentTimeMillis(), val userId: String, val deviceId: String, val action: AuditAction, val resourceId: String?, val resourceType: String?, val metadata: Map<String, String> = emptyMap(), val synced: Boolean = false ) enum class AuditAction { LOGIN, LOGOUT, DOCUMENT_VIEW, DOCUMENT_EXPORT, RECORD_CREATE, RECORD_UPDATE, RECORD_DELETE, AUTH_FAILURE, SETTINGS_CHANGE, WIPE_RECEIVED } // DAO for local queue @Dao interface AuditEventDao { @Insert suspend fun insert(event: AuditEvent) @Query("SELECT * FROM audit_events WHERE synced = 0 ORDER BY timestamp ASC LIMIT 50") suspend fun getUnsynced(): List<AuditEvent> @Query("UPDATE audit_events SET synced = 1 WHERE id IN (:ids)") suspend fun markSynced(ids: List<String>) } The sync task runs when network is available and on app launch. Batched sending of 50 events per batch balances server load and delivery speed.
Why Is Log Integrity Important?
If the app runs on a rooted/jailbroken device, the user can delete the local SQLite. For high-security requirements, each event is signed with an HMAC key from Android Keystore / iOS Secure Enclave:
fun signEvent(event: AuditEvent): String { val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) } val privateKey = keyStore.getKey("audit_signing_key", null) val signature = Signature.getInstance("SHA256withECDSA") signature.initSign(privateKey as PrivateKey) signature.update(event.toCanonicalBytes()) return Base64.encodeToString(signature.sign(), Base64.NO_WRAP) } The server verifies the signature using the public key. Forging a log without Secure Enclave access is impossible.
Context Enrichment
Bare userId + action + timestamp is the minimum. Useful additions:
-
deviceId— binds to a specific device, not an account -
appVersion— to understand which version the incident occurred on -
networkType(WiFi/LTE/VPN) — shows whether the corporate VPN was active -
jailbreak/root detected— flags from SafetyNet / DeviceCheck
On Android, deviceId is Settings.Secure.ANDROID_ID (unique per device+user+app combination since Android 8). On iOS, it is UIDevice.current.identifierForVendor.
Storage on the Server
Audit logs are not deleted after 30 days. Legal requirements (depending on industry): from 1 year (standard) to 7 years (financial organizations under Federal Law 115). Store in an append-only database — PostgreSQL with INSERT-only tables and UPDATE/DELETE prohibition via Row Level Security, or a separate SIEM (Splunk, ELK with ILM). ISO 27001 recommends storing logs for at least 1 year.
For storage, PostgreSQL with RLS is simpler and sufficient for up to 10 million records; beyond that, SIEM provides faster search and automated rotation, but at 2–3x higher cost. We recommend PostgreSQL for most mid-size enterprises and SIEM for large banks or healthcare.
What Does Our Work Include?
We provide a full range of services for audit trail implementation:
| Stage | Result |
|---|---|
| Current logging audit | Report with identified issues and recommendations |
| Event schema design | Document listing events and metadata |
| Local queue implementation | Code with WorkManager/BGProcessingTask and SQLite |
| HMAC event signing | Integration with Keystore/Enclave, server verification |
| Server integration | API endpoint with append-only table |
| Documentation and training | Instructions for administrators and developers |
| Post-implementation support | 1 month of bug fixes and tweaks |
| Compliance deliverables | Access to audit-ready logs, SIEM dashboards |
Timeline: 2 to 6 days depending on complexity. Typical project cost starts at $5,000, with savings of 30% in internal audit preparation and a 50% faster incident response. We offer a free initial consultation to scope your needs. Contact us to discuss details.
What to Check During App Audit?
We often find that the app already has 'some logging' — but it writes to Logcat or a file in cacheDir, which gets cleared when space runs low. That is not an audit trail; it is junk. Our team conducts an audit and shows how to fix the situation.
Local queue implementation example
Code for AuditEventDao and WorkManager is available above. Full project can be requested from us.
The implementation process includes the following steps:
- Requirement analysis and current logging audit.
- Event and metadata schema design.
- Local queue implementation with guaranteed delivery.
- HMAC signing for integrity.
- Server storage integration (PostgreSQL or SIEM).
- Testing and team training.
Note: Compliance with App Store Review Guidelines (Sections 4.2 and 5.1) is ensured through proper logging and privacy handling.







