A


Federal software often handles sensitive data, operates under strict compliance requirements, and must withstand both accidental misuse and deliberate attack. Interviewers ask this to assess whether you can build secure systems by default, not bolt security on later.
Explain the secure coding practices you follow when building software for federal clients.
Address these points:
The interviewer expects a practical engineering answer, not a legal or policy deep dive. Focus on concrete coding and design habits, how they reduce risk, and how you would prioritize them in a production environment.
Treat all external input as untrusted, even if it comes from internal systems. Validate format, length, type, and allowed values early, and encode output appropriately to prevent injection and cross-context attacks.
import re
def is_valid_username(name):
return bool(re.fullmatch(r"[A-Za-z0-9_-]{3,32}", name))
Applications, services, and users should have only the permissions they need. Strong authorization checks must be enforced server-side for every sensitive action rather than relying on client behavior.
def can_view_record(user, record):
return user.role == 'auditor' or record.owner_id == user.id
Secrets should never be hardcoded in source code or configuration checked into version control. Dependencies must be pinned, scanned, and updated regularly because third-party libraries are a common attack path.
# Bad: API_KEY = 'hardcoded-secret'
# Better: read from environment or a secrets manager
Logs should support investigation without exposing credentials, tokens, PII, or classified data. Error messages returned to users should be minimal, while detailed diagnostics go to protected internal logs.
def redact(token):
return token[:4] + '...' if token else ''
Secure coding is not just about implementation details; it also includes code review, static analysis, threat modeling, and security testing. These practices catch issues earlier and reduce the chance that insecure patterns reach production.