Skip to content

Security: aioutlet/order-service

.github/SECURITY.md

Security Policy

Overview

The Order Service is a critical .NET 8 microservice responsible for order management, processing, and lifecycle tracking within the AIOutlet platform. It handles sensitive customer data, payment information references, and financial transactions.

Supported Versions

We provide security updates for the following versions:

Version Supported
1.0.x
< 1.0

Security Features

.NET Security Framework

  • ASP.NET Core Security: Built-in security features and middleware
  • JWT Bearer Authentication: Secure token-based authentication
  • Entity Framework Core: Secure ORM with parameterized queries
  • FluentValidation: Comprehensive input validation framework

Data Protection

  • Data Protection API: ASP.NET Core data protection for sensitive data
  • Connection String Security: Encrypted database connections
  • Azure Identity Integration: Secure cloud authentication
  • Secrets Management: Azure Key Vault integration for production

Order Processing Security

  • Order State Validation: Secure order lifecycle management
  • Payment Integration Security: Secure payment service communication
  • Inventory Validation: Stock verification with inventory service
  • Audit Trail: Comprehensive order activity logging

Message Queue Security

  • RabbitMQ Security: Secure AMQP communication
  • Azure Service Bus: Enterprise-grade message security
  • Message Encryption: Encrypted inter-service communication
  • Queue Authentication: Authenticated message broker access

Monitoring & Observability

  • Serilog Security: Structured logging with sensitive data protection
  • OpenTelemetry: Distributed tracing with security context
  • Health Checks: Comprehensive service health monitoring
  • Metrics Collection: Secure performance metrics gathering

Security Best Practices

For Developers

  1. Configuration Security: Secure appsettings management

    {
      "ConnectionStrings": {
        "DefaultConnection": "Host=localhost;Database=OrderService;Username=orderuser;Password=***;SSL Mode=Require"
      },
      "JwtSettings": {
        "SecretKey": "*** (use environment variables)",
        "Issuer": "AIOutlet.OrderService",
        "Audience": "AIOutlet.Platform",
        "ExpirationMinutes": 60
      },
      "AzureServiceBus": {
        "ConnectionString": "*** (use managed identity)",
        "QueueName": "order-processing"
      }
    }
  2. Input Validation: FluentValidation for comprehensive validation

    public class CreateOrderValidator : AbstractValidator<CreateOrderRequest>
    {
        public CreateOrderValidator()
        {
            RuleFor(x => x.CustomerId)
                .NotEmpty()
                .Must(BeValidGuid).WithMessage("Invalid customer ID format");
    
            RuleFor(x => x.Items)
                .NotEmpty()
                .Must(HaveValidItems).WithMessage("Order must contain valid items");
    
            RuleFor(x => x.PaymentMethod)
                .NotEmpty()
                .MaximumLength(50);
        }
    }
  3. Secure Database Access: Entity Framework best practices

    // Secure repository pattern with EF Core
    public async Task<Order> GetOrderByIdAsync(Guid orderId, Guid customerId)
    {
        return await _context.Orders
            .Where(o => o.Id == orderId && o.CustomerId == customerId)
            .Include(o => o.Items)
            .FirstOrDefaultAsync();
    }
    
    // Avoid dynamic SQL, use parameterized queries
    public async Task<IEnumerable<Order>> GetOrdersByStatusAsync(OrderStatus status)
    {
        return await _context.Orders
            .Where(o => o.Status == status)
            .ToListAsync();
    }
  4. Authentication Middleware: Secure JWT implementation

    // JWT authentication configuration
    services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddJwtBearer(options =>
        {
            options.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuer = true,
                ValidateAudience = true,
                ValidateLifetime = true,
                ValidateIssuerSigningKey = true,
                ValidIssuer = jwtSettings.Issuer,
                ValidAudience = jwtSettings.Audience,
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.SecretKey))
            };
        });

For Deployment

  1. Environment Security:

    • Use Azure Key Vault for secrets in production
    • Enable Application Insights for monitoring
    • Configure HTTPS redirection and HSTS
    • Implement proper CORS policies
  2. Database Security:

    • Enable PostgreSQL SSL connections
    • Use connection pooling with limits
    • Implement database migrations security
    • Regular security patches
  3. Cloud Security:

    • Use Azure Managed Identity
    • Configure network security groups
    • Enable Azure Security Center
    • Implement Azure Policy compliance

Data Handling

Sensitive Data Categories

  1. Customer Order Data:

    • Customer identifiers and contact information
    • Order details and item information
    • Shipping and billing addresses
    • Order status and history
  2. Payment References:

    • Payment method identifiers (not actual payment data)
    • Payment status and transaction references
    • Refund and adjustment information
    • Payment processor correlation IDs
  3. Business Data:

    • Order pricing and tax calculations
    • Shipping costs and methods
    • Discount and promotion applications
    • Order fulfillment data

Data Protection Measures

  • Data Protection API: ASP.NET Core data protection for PII
  • Database Encryption: PostgreSQL encryption at rest
  • Transport Security: TLS 1.3 for all communications
  • Field Encryption: Sensitive fields encrypted at application level

Data Retention

  • Order records: 7 years (financial compliance)
  • Order history: 5 years (customer service)
  • Payment references: 7 years (financial audit)
  • Customer data: Until account deletion (GDPR compliance)

Vulnerability Reporting

Reporting Security Issues

Order service vulnerabilities can affect financial transactions:

  1. Do NOT open a public issue
  2. Do NOT attempt to manipulate order data
  3. Email our security team at: security@aioutlet.com

Critical Security Areas

  • Order manipulation or unauthorized access
  • Payment reference exposure
  • Customer data leakage
  • Order state manipulation
  • Financial calculation tampering

Response Timeline

  • 4 hours: Critical financial/payment issues
  • 8 hours: High severity customer data exposure
  • 24 hours: Medium severity access issues
  • 72 hours: Low severity issues

Severity Classification

Severity Description Examples
Critical Financial manipulation, customer data breach Order tampering, PII exposure
High Authentication bypass, unauthorized access JWT bypass, privilege escalation
Medium Information disclosure, business logic flaws Order data leak, validation bypass
Low Minor security improvements Logging issues, configuration problems

Security Testing

Order-Specific Testing

Regular security assessments should include:

  • Order manipulation and state validation testing
  • Customer data access control verification
  • Payment reference security testing
  • Message queue security validation
  • Database injection vulnerability testing

Automated Security Testing

  • Unit tests for order validation and business logic
  • Integration tests for secure order processing flows
  • Load testing for high-volume order processing
  • Security tests for authentication and authorization

Security Configuration

Required Environment Variables

# Database Configuration
ConnectionStrings__DefaultConnection="Host=server;Database=OrderService;Username=user;Password=***;SSL Mode=Require"

# JWT Configuration
JwtSettings__SecretKey="your-256-bit-secret-key"
JwtSettings__Issuer="AIOutlet.OrderService"
JwtSettings__Audience="AIOutlet.Platform"
JwtSettings__ExpirationMinutes=60

# Azure Integration
AZURE_CLIENT_ID="managed-identity-client-id"
AZURE_TENANT_ID="azure-tenant-id"
AZURE_SUBSCRIPTION_ID="azure-subscription-id"

# Message Queue Security
AzureServiceBus__ConnectionString="Endpoint=sb://namespace.servicebus.windows.net/;Authentication=Managed Identity"
RabbitMQ__ConnectionString="amqps://user:password@server:5672/vhost"

# Logging and Monitoring
Serilog__MinimumLevel="Information"
ApplicationInsights__InstrumentationKey="instrumentation-key"
OpenTelemetry__Endpoint="http://jaeger:14268/api/traces"

# Security Headers
Security__EnableHsts=true
Security__HstsMaxAge=31536000
Security__EnableCsp=true
Security__CorsOrigins="https://app.aioutlet.com,https://admin.aioutlet.com"

C# Security Configuration

// Startup security configuration
public void ConfigureServices(IServiceCollection services)
{
    // Security headers
    services.AddHsts(options =>
    {
        options.Preload = true;
        options.IncludeSubDomains = true;
        options.MaxAge = TimeSpan.FromDays(365);
    });

    // CORS configuration
    services.AddCors(options =>
    {
        options.AddPolicy("AllowedOrigins", builder =>
        {
            builder.WithOrigins(Configuration["Security:CorsOrigins"].Split(','))
                   .AllowAnyMethod()
                   .AllowAnyHeader()
                   .AllowCredentials();
        });
    });

    // Data protection
    services.AddDataProtection()
        .PersistKeysToAzureBlobStorage(connectionString, containerName, blobName)
        .ProtectKeysWithAzureKeyVault(keyIdentifier, credential);
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // Security middleware pipeline
    app.UseHttpsRedirection();
    app.UseHsts();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseCors("AllowedOrigins");
}

.NET Security Best Practices

Code Security

  1. Secure Coding: Follow .NET secure coding guidelines
  2. Input Validation: Use FluentValidation for all inputs
  3. Output Encoding: Prevent XSS in API responses
  4. Exception Handling: Avoid information disclosure in exceptions

Dependency Management

  1. NuGet Security: Regular package updates and vulnerability scanning
  2. Package Validation: Verify package signatures and sources
  3. Dependency Auditing: Monitor for known vulnerabilities
  4. Private Feeds: Use private NuGet feeds for internal packages

Compliance

The Order Service adheres to:

  • PCI DSS: Payment card industry security standards
  • SOX: Financial reporting and audit controls
  • GDPR: Customer data protection and privacy
  • CCPA: California consumer privacy requirements
  • .NET Security: Microsoft security best practices

Performance & Security

High-Performance Security

  • Async/Await Patterns: Non-blocking secure operations
  • Connection Pooling: Secure database connection management
  • Caching Security: Secure Redis/memory caching
  • Load Balancing: Security-aware request distribution

Incident Response

Order Security Incidents

  1. Order Tampering: Immediate order freeze and audit
  2. Customer Data Breach: GDPR breach notification process
  3. Payment Issue: Coordinate with payment service team
  4. Service Compromise: Azure security response procedures

Recovery Procedures

  • Order data restoration from secure backups
  • Customer notification for data breaches
  • Financial reconciliation for affected orders
  • Service hardening and security updates

Contact

For security-related questions or concerns:


Last Updated: September 8, 2025
Next Review: December 8, 2025
Version: 1.0.0

There aren’t any published security advisories