Skip to main content

Request Signing

Add an extra layer of security to your routes with cryptographic request signing. Verify that requests haven’t been tampered with and prevent replay attacks.

What is Request Signing?

Request signing uses HMAC-SHA256 (Hash-based Message Authentication Code) to create a cryptographic signature of each request. This signature proves:
  • Authenticity: Request came from a trusted source
  • Integrity: Request wasn’t modified in transit
  • Non-repudiation: Sender cannot deny sending the request

Why Use Request Signing?

Without Request Signing

With Request Signing

How It Works

Signature Creation (Client Side)

  1. Get current timestamp (Unix seconds):
  1. Create payload to sign:
  1. Create HMAC-SHA256 signature:
  1. Format signature header:
Format: t=<timestamp>,v1=<signature>
  • t=: Unix timestamp when request was created
  • v1=: HMAC-SHA256 signature in hexadecimal
  1. Include in request headers:

Signature Verification (KnoxCall)

  1. Extract signature and timestamp from headers
  2. Recreate the message from request components
  3. Compute expected signature using shared secret
  4. Compare signatures:
    • Match → Request is valid ✅
    • Mismatch → Request is rejected ❌

Setting Up Request Signing

Step 1: Enable on Route

  1. Navigate to Routes → Select your route
  2. Scroll to Security section
  3. Toggle Require Signature to ON
  4. Configure settings:
Signature Header:
(Default, can be customized) Timestamp Header:
(Default, can be customized) Signature Algorithm:
(Most secure and widely supported) Timestamp Tolerance:
Allows clock skew between client and server.
  1. Click Save

Step 2: Create Signing Secret

  1. Navigate to SecretsAdd Secret
  2. Configure:
Name:
Type:
Value:
Recommended: Use a cryptographically secure random string:
  1. Click Save

Step 3: Assign Secret to Client

  1. Navigate to Clients → Select your client
  2. Go to Signing Configuration tab
  3. Select the signing secret
  4. Click Save
Now this client must sign all requests to protected routes.

Client Implementation

JavaScript/Node.js

Python

Go

PHP

Signature Verification Process

KnoxCall performs the following checks:

1. Timestamp Validation

Rejected if:
  • Timestamp is more than 5 minutes old
  • Timestamp is in the future (clock skew)

2. Signature Recreation

3. Signature Comparison

Preventing Replay Attacks

Request signing combined with timestamps prevents replay attacks:

Replay Attack Window

Request signing uses timestamp validation to prevent replays. A request signed at time T is accepted for signature_tolerance_sec seconds (default 300 / 5 minutes). After that window, the same signed request is rejected.
Within the tolerance window, a replay technically passes signature validation — because KnoxCall does not track request nonces. For endpoints where this matters (e.g. idempotency-critical mutations), enforce your own deduplication at the application layer using a request ID or idempotency key.

Error Responses

Invalid Signature

Timestamp Too Old

Missing Headers

Best Practices

1. Use Strong Secrets

Generate cryptographically secure signing secrets:
Bad:
  • password123
  • my-secret-key
  • Short or predictable strings

2. Rotate Secrets Regularly

Rotate signing secrets every 90 days:
  1. Create new secret
  2. Update clients with new secret (gracefully)
  3. Support both old and new secrets for 24 hours
  4. Remove old secret

3. Use HTTPS Always

Request signing protects integrity, but not confidentiality:
Always use HTTPS + request signing together.

4. Include All Relevant Data

Sign everything that matters:

5. Handle Clock Skew

Allow 5-minute tolerance for client clock differences:

Use Cases

Payment Processing

Administrative Actions

Webhook Validation

High-Value Transactions

Troubleshooting

”Invalid signature” errors

Check:
  • ✓ Using the correct signing secret
  • ✓ Message format matches exactly (order matters)
  • ✓ Body is JSON-stringified identically
  • ✓ No extra whitespace in headers
Debug: Log the message before signing:

“Timestamp expired” errors

Causes:
  • Client clock is out of sync
  • Request took too long to reach KnoxCall
  • Network latency
Fix:
  • Sync client clock with NTP
  • Increase timestamp tolerance (temporarily for testing)
  • Reduce request queuing on client side

Signature works in test but not production

Check:
  • ✓ Using production signing secret (not test secret)
  • ✓ Correct route configuration in production
  • ✓ Client is assigned to production environment

Next Steps

Rate Limiting

Add rate limits for additional protection

Secret Management

Learn about managing signing secrets

Client Permissions

Configure client-level security

OAuth2 Flow

Set up OAuth2 authentication

📊 Statistics

  • Level: advanced
  • Time: 20 minutes

🏷️ Tags

security, hmac, signatures, authentication, integrity