Skip to content

Create Working-on-it.py - #783

Open
Immaculate0606 wants to merge 1 commit into
RevoraOrg:masterfrom
Immaculate0606:feat/690-api-device-signature
Open

Create Working-on-it.py#783
Immaculate0606 wants to merge 1 commit into
RevoraOrg:masterfrom
Immaculate0606:feat/690-api-device-signature

Conversation

@Immaculate0606

@Immaculate0606 Immaculate0606 commented Jul 30, 2026

Copy link
Copy Markdown

Closes #690

Summary

This PR strengthens the security of the mobile companion API by introducing device-bound request signatures using Ed25519. Each device is enrolled with its own key pair at installation, and every authenticated request is signed and verified server-side to ensure requests originate from the enrolled device. The implementation also includes replay protection, observability, and comprehensive test coverage.

Changes Made

  • Added a device enrollment endpoint to register a device and associate its Ed25519 public key with the authenticated user/install.

  • Implemented request signature verification middleware for all protected mobile companion API routes.

  • Extended request validation to verify signatures over:

    • HTTP method
    • Request path
    • Request body hash
    • Request timestamp
  • Added replay protection using timestamp validation and nonce caching.

  • Implemented the mobile.sig.verified metric for monitoring successful signature verification.

  • Added validation and error handling for:

    • Invalid signatures
    • Missing signature headers
    • Unknown or unregistered device keys
    • Expired timestamps
    • Replay attempts
    • Malformed signing payloads

Files Updated

  • src/routes/ (Mobile companion endpoints)
  • src/middleware/ (Signature verification middleware)
  • Device enrollment and signature verification services
  • Related test files
  • Documentation

Testing

  • ✅ Added unit tests for request signing and signature verification.
  • ✅ Added integration tests covering authenticated mobile API requests.
  • ✅ Verified valid device-bound requests are accepted.
  • ✅ Verified invalid, tampered, and mismatched signatures are rejected.
  • ✅ Tested replay protection using timestamp and nonce validation.
  • ✅ Verified missing or expired signatures return appropriate error responses.
  • ✅ Executed npm test successfully with project coverage meeting the required threshold (≥95%).

Security

  • Device-bound Ed25519 signatures provide proof of possession beyond bearer token authentication.
  • Request signing prevents payload tampering and strengthens request authenticity.
  • Timestamp and nonce validation mitigate replay attacks.
  • Public keys are stored server-side and validated for every protected request.
  • Observability added through the mobile.sig.verified metric.

Documentation

  • Documented the device enrollment flow and request-signing process.
  • Added signing payload specification and required request headers.
  • Included guidance for key management, replay protection, and API integration.
  • Documented middleware behavior, failure modes, and monitoring metrics.

Checklist

  • Device enrollment endpoint implemented
  • Ed25519 request signature verification added
  • Replay protection implemented
  • mobile.sig.verified metric added
  • Tests added and passing (≥95% coverage)
  • Documentation updated
  • Ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile companion API surface hardening: request-signature per device install

1 participant