Skip to content

Security Best Practices

This guide outlines security best practices for using the PaiTIENT Secure Model Service in a HIPAA and SOC2 compliant manner.

Overview

The PaiTIENT Secure Model Service is designed with security as a core principle. While the service provides built-in security features, following these best practices will help ensure your deployments maintain the highest security standards.

API Key Management

Secure Storage

  • Never hardcode API keys in your source code
  • Use environment variables or secure credential stores
  • Rotate API keys regularly, at least every 90 days
  • Use different API keys for development and production environments

Example: Secure Environment Variable Usage

python
# Python example
import os
from paitient_secure_model import Client

# Load API key from environment variable
client = Client(
    api_key=os.environ.get("PAITIENT_API_KEY"),
    client_id=os.environ.get("PAITIENT_CLIENT_ID")
)
javascript
// JavaScript example
const { PaiTIENTClient } = require('paitient-secure-model');

// Load API key from environment variable
const client = new PaiTIENTClient({
  apiKey: process.env.PAITIENT_API_KEY,
  clientId: process.env.PAITIENT_CLIENT_ID
});

Network Security

Secure Connections

  • Enable network isolation for sensitive deployments
  • Use private endpoints when possible
  • Configure IP-based restrictions for API access
  • Implement proper VPC settings for network isolation

Example: Private Endpoint Configuration

python
# Python example
from paitient_secure_model import Client
from paitient_secure_model.security import SecuritySettings

client = Client()

deployment = client.create_deployment(
    model_name="ZimaBlueAI/HuatuoGPT-o1-8B",
    deployment_name="secure-deployment",
    security_settings=SecuritySettings(
        network_isolation=True,
        private_endpoints=True,
        allowed_ip_ranges=["10.0.0.0/8"]
    ),
    vpc_config={
        "subnet_ids": ["subnet-abc123", "subnet-def456"],
        "security_group_ids": ["sg-123456"]
    }
)

Data Protection

Prompt and Response Security

  • Minimize sensitive data in prompts
  • Implement PHI/PII detection and redaction
  • Use content filtering for user-provided inputs
  • Apply appropriate data retention policies

Example: PHI Detection and Redaction

python
# Python example
from paitient_secure_model import Client
from paitient_secure_model.security import SecuritySettings, DataFiltering

client = Client()

response = client.generate_text(
    deployment_id="dep_12345abcde",
    prompt="Summarize treatment options for diabetes",
    security_settings=SecuritySettings(
        data_filtering=DataFiltering(
            detect_pii=True,
            redact_phi=True,
            content_filtering="strict"
        )
    )
)

Compliance Controls

HIPAA Compliance

  • Enable audit logging for all operations
  • Implement appropriate access controls
  • Maintain encryption for data at rest and in transit
  • Document compliance practices

Example: HIPAA-Compliant Configuration

python
# Python example
from paitient_secure_model import Client
from paitient_secure_model.security import SecuritySettings, ComplianceSettings

client = Client(
    security_settings=SecuritySettings(
        compliance=ComplianceSettings(
            hipaa=True,
            audit_logging=True,
            log_retention_days=365
        )
    )
)

Authentication and Authorization

Multi-Factor Authentication

  • Enable MFA for all administrative accounts
  • Require MFA for API key generation
  • Use temporary credentials for automated processes

Role-Based Access Control

  • Apply least privilege principle
  • Use role-based access control
  • Regularly audit access permissions

Secure Development Practices

Code Security

  • Review code for security vulnerabilities
  • Use automated security scanning
  • Keep dependencies updated
  • Implement secure input validation

Example: Secure Input Handling

python
# Python example
def validate_prompt(prompt):
    """Validate and sanitize user input."""
    if not prompt or len(prompt) > 4000:
        raise ValueError("Prompt must be between 1 and 4000 characters")
    
    # Check for potentially harmful content
    if any(pattern in prompt.lower() for pattern in ["<script>", "exec(", "system("]):
        raise ValueError("Prompt contains potentially harmful content")
    
    return prompt

# Use the validated prompt
try:
    sanitized_prompt = validate_prompt(user_input)
    response = client.generate_text(
        deployment_id="dep_12345abcde",
        prompt=sanitized_prompt
    )
except ValueError as e:
    print(f"Input validation error: {e}")

Monitoring and Incident Response

Security Monitoring

  • Enable enhanced monitoring
  • Set up alerting for suspicious activities
  • Regularly review audit logs
  • Monitor for unusual access patterns

Incident Response

  • Develop an incident response plan
  • Regularly test your response procedures
  • Document security incidents
  • Learn from security events

Multi-tenant Security

Tenant Isolation

  • Use strong tenant isolation
  • Implement separate encryption keys per tenant
  • Maintain strict access boundaries
  • Regularly test isolation controls

Example: Multi-tenant Security

python
# Python example
from paitient_secure_model import Client
from paitient_secure_model.security import SecuritySettings, MultiTenancySettings

client = Client(
    multi_tenant=True,
    security_settings=SecuritySettings(
        multi_tenancy=MultiTenancySettings(
            isolation_level="strong",
            separate_encryption_keys=True,
            tenant_boundary_enforcement="strict"
        )
    )
)

# Generate text for a specific tenant
response = client.generate_text(
    deployment_id="dep_12345abcde",
    prompt="Summarize treatment options for diabetes",
    tenant_id="tenant_12345"
)

Physical and Environmental Security

Data Center Security

  • Use HIPAA-compliant data centers
  • Implement physical access controls
  • Maintain environmental safeguards
  • Regularly audit physical security

Security Checklist

Before deploying to production, ensure you've addressed these key security areas:

  • [ ] API Keys: Securely stored, regularly rotated
  • [ ] Network Security: Private endpoints, IP restrictions
  • [ ] Data Protection: PHI/PII detection, content filtering
  • [ ] Authentication: MFA enabled, strong password policies
  • [ ] Authorization: Least privilege access, role-based controls
  • [ ] Encryption: Data encrypted at rest and in transit
  • [ ] Monitoring: Security events monitored, alerts configured
  • [ ] Compliance: HIPAA/SOC2 controls implemented
  • [ ] Incident Response: Plan documented and tested
  • [ ] Documentation: Security practices documented

Next Steps

Released under the MIT License.