Enterprise Android Security Attestation Automation Generator
Generate an automated Android security verification script for enterprise client hardware attestation and certificate pinning audits.
Use this template when auditing or automating security compliance for client-facing enterprise Android applications. It creates a robust validation script testing hardware keystore integrity, SSL pinning, and tamper responses.
Role: Principal Android Security Consultant specializing in mobile enterprise defense and cryptographic validation.
Context
- Client engagement: {{client_firm_name}}
- Compiled package artifact: {{target_apk_path}}
- Keystore alias for signing: {{keystore_alias}}
- Verification attestation server: {{attestation_endpoint}}
- Target compliance benchmark: {{compliance_standard}}
- Minimum supported platform level: {{minimum_api_level}}
Task
Generate a production-ready shell and Python test automation script that connects to connected physical test devices via ADB, executes Play Integrity and KeyStore hardware-backed attestation checks, verifies network security config pinning against {{attestation_endpoint}}, and exports an audit-ready compliance artifact for {{client_firm_name}}.
Method
- Initialize environment parameters and validate device connectivity over ADB targeting {{minimum_api_level}}.
- Extract package metadata from {{target_apk_path}} and verify APK signature scheme integrity against {{keystore_alias}}.
- Inject a local proxy certificate to dynamically test that certificate pinning rejects unauthorized TLS handshakes.
- Trigger an instrumented hardware attestation challenge against the Android Keystore to verify hardware-backed key storage.
- Query the Play Integrity API via {{attestation_endpoint}} and parse verdict payloads for basic integrity, device recognition, and licensing status.
- Execute root and runtime tamper detection probes, asserting proper defensive termination behavior.
- Format all assertion results into structured JSON and an executive compliance summary mapped to {{compliance_standard}}.
Constraints
- MUST output fully executable, posix-compliant Bash and Python 3 automation scripts without pseudo-code placeholders.
- MUST NOT hardcode plaintext passwords, raw private keys, or internal API tokens into the generated code.
- All ADB commands MUST handle multi-device environments gracefully using device targeting flags.
- Error handling MUST fail closed with descriptive standard error codes upon any security assertion failure.
Output format
- Section 1: Prerequisites and Environment Configuration
- Section 2: Complete Test Harness Script (Bash/Python code block, 80-140 lines)
- Section 3: Sample Execution Command and JSON Output Schema
- Section 4: Security Remediation Guide (maximum 300 words)
Self-review
- Ensure all variables ({{client_firm_name}}, {{target_apk_path}}, {{keystore_alias}}, {{attestation_endpoint}}, {{compliance_standard}}, {{minimum_api_level}}) are actively used in the script.
- Verify that network security failure paths explicitly check for trust anchor rejections.
- Check that the script executes cleanly in a continuous integration environment without interactive prompts.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.