Skip to content

Latest commit

 

History

History
222 lines (195 loc) · 5.89 KB

File metadata and controls

222 lines (195 loc) · 5.89 KB

SecurePDF (SPDF) Format Specification

Version 1.0.0

Overview

SecurePDF (SPDF) is a secure document format designed to prevent malicious code injection, ensure document integrity, and provide end-to-end encryption. Unlike traditional PDF, SPDF uses a JSON-based structure with mandatory cryptographic signatures.

Core Security Features

  • No Arbitrary Code Execution: No PostScript, JavaScript, or embedded executables
  • Cryptographic Signatures: Mandatory digital signatures with certificate chains
  • Content Validation: Strict validation of all document components
  • End-to-End Encryption: AES-256-GCM encryption for content
  • Integrity Verification: SHA-3 hashes for each document component
  • Modification History: Blockchain-style audit trail

File Structure

{
  "spdf": {
    "version": "1.0.0",
    "created": "2025-01-24T10:00:00Z",
    "id": "uuid-v4"
  },
  "metadata": {
    "title": "Document Title",
    "author": "Author Name",
    "subject": "Subject",
    "keywords": ["keyword1", "keyword2"],
    "permissions": {
      "print": true,
      "copy": false,
      "modify": false,
      "annotate": true
    }
  },
  "security": {
    "encryption": {
      "algorithm": "AES-256-GCM",
      "key_derivation": "PBKDF2",
      "salt": "base64-encoded-salt",
      "iterations": 100000
    },
    "signature": {
      "algorithm": "RSA-PSS",
      "hash_algorithm": "SHA3-256",
      "certificate": "base64-encoded-cert",
      "signature": "base64-encoded-signature",
      "timestamp": "RFC3161-timestamp"
    },
    "content_hashes": {
      "text": "sha3-256-hash",
      "images": ["sha3-256-hash1", "sha3-256-hash2"],
      "forms": "sha3-256-hash"
    }
  },
  "content": {
    "pages": [
      {
        "id": "page-uuid",
        "width": 595.28,
        "height": 841.89,
        "elements": [
          {
            "type": "text",
            "id": "text-uuid",
            "x": 72,
            "y": 720,
            "width": 451.28,
            "height": 20,
            "content": "encrypted-base64-text",
            "style": {
              "font": "Arial",
              "size": 12,
              "color": "#000000",
              "bold": false,
              "italic": false
            }
          },
          {
            "type": "image",
            "id": "image-uuid",
            "x": 72,
            "y": 600,
            "width": 200,
            "height": 100,
            "format": "PNG",
            "data": "encrypted-base64-image",
            "alt": "Image description"
          }
        ]
      }
    ],
    "forms": {
      "fields": [
        {
          "id": "field-uuid",
          "type": "text",
          "name": "field_name",
          "page": 0,
          "x": 72,
          "y": 500,
          "width": 200,
          "height": 20,
          "required": false,
          "validation": {
            "type": "text",
            "max_length": 100,
            "pattern": "^[a-zA-Z0-9\\s]+$"
          }
        }
      ]
    }
  },
  "audit_trail": [
    {
      "timestamp": "2025-01-24T10:00:00Z",
      "action": "created",
      "user": "user-certificate-fingerprint",
      "previous_hash": null,
      "hash": "sha3-256-hash"
    }
  ]
}

Security Model

1. Encryption Layer

  • Content is encrypted using AES-256-GCM
  • Key derivation uses PBKDF2 with high iteration count
  • Unique salt per document
  • Authenticated encryption prevents tampering

2. Digital Signatures

  • Mandatory RSA-PSS signatures with SHA3-256
  • X.509 certificate chains for identity verification
  • RFC3161 timestamping for non-repudiation
  • Signature covers entire document structure

3. Content Validation

  • Whitelist-based element types (text, image, form)
  • Strict validation of allowed image formats (PNG, JPEG, WebP)
  • No embedded scripts or executable content
  • Form validation with safe input patterns

4. Integrity Protection

  • SHA3-256 hashes for each content element
  • Merkle tree structure for efficient verification
  • Tamper detection through hash validation
  • Audit trail with blockchain-like properties

Supported Features

Text Elements

  • UTF-8 text content
  • Standard fonts (Arial, Times, Helvetica, Courier)
  • Basic styling (bold, italic, color, size)
  • No dynamic content or scripts

Images

  • PNG, JPEG, WebP formats only
  • Maximum resolution: 4096x4096
  • Embedded as encrypted base64
  • Alt text for accessibility

Forms

  • Text inputs with validation
  • Checkboxes and radio buttons
  • Dropdown selections
  • No executable form actions

Annotations

  • Simple text annotations
  • Highlights and notes
  • No rich media or scripts

Implementation Guidelines

Parser Requirements

  • Strict JSON schema validation
  • Certificate chain verification
  • Signature validation before content access
  • Hash verification for all elements
  • Sandboxed execution environment

Viewer Requirements

  • No JavaScript execution
  • Secure image rendering
  • Form validation on client side
  • Audit trail display
  • Permission enforcement

Generator Requirements

  • Mandatory signature generation
  • Content encryption before serialization
  • Hash calculation for all elements
  • Audit trail maintenance
  • Certificate validation

Security Considerations

  1. No Code Execution: Complete elimination of script execution vectors
  2. Input Validation: Strict validation of all document elements
  3. Cryptographic Protection: Industry-standard encryption and signatures
  4. Certificate Management: Proper PKI infrastructure required
  5. Audit Trail: Immutable history of document modifications
  6. Permission Enforcement: Client-side permission validation
  7. Sandboxing: Isolated execution environment for viewers

Compliance

  • FIPS 140-2 Level 2 cryptographic requirements
  • Common Criteria EAL4+ security profile
  • GDPR compliance for personal data protection
  • ISO 27001 information security standards

Version History

  • v1.0.0: Initial specification release