Data Security
Data security protects data from unauthorized access, tampering, and loss with encryption, access control, and audits, including AI datasets and weights.
Data security is the protection of digital data from unauthorized access, theft, tampering, and loss throughout its lifecycle, from collection and storage through processing, sharing, and deletion. Its goals are usually stated as the CIA triad: confidentiality, so that only authorized people and systems can read the data; integrity, so that it stays accurate and unaltered; and availability, so that it can be used when needed. The NIST Cybersecurity Framework 2.0, published in February 2024, organizes the work into six functions: govern, identify, protect, detect, respond, and recover. In machine learning, the data to protect includes training data and its labels, model weights that encode what was learned from that data, the images and prompts sent for inference, and the logs that record them.
Core Controls#
Data security combines several layers, so that one failed control does not expose everything:
- Encryption: Data at rest is encrypted with ciphers such as AES-256, and data in transit travels over TLS.
- Access control: Each person and service gets the least privilege it needs, through roles, multi-factor authentication, and short-lived credentials in place of shared passwords.
- Key and secret management: Encryption keys live in a key management service or hardware security module, separate from the data, and are rotated on a schedule. API keys stay out of source code and notebooks.
- Integrity checks and backups: Checksums and digital signatures detect altered files, and versioned, immutable backups allow recovery from ransomware or accidental deletion.
- Audit logging: Every read, write, and permission change is recorded, so that unusual access, such as one account downloading a whole dataset at night, can be detected and investigated.
Authenticated encryption provides confidentiality and integrity together. This example uses Fernet from the Python cryptography package to encrypt a label file line and then detect a single flipped bit:
import base64
from cryptography.fernet import Fernet, InvalidToken
# In production the key comes from a key management service and is never stored with the data
cipher = Fernet(Fernet.generate_key())
label = b"0 0.48 0.63 0.21 0.37\n" # one YOLO annotation line
token = cipher.encrypt(label) # AES-128-CBC ciphertext plus an HMAC-SHA256 tag
print(cipher.decrypt(token) == label)
# Flip one bit of the stored ciphertext, as tampering or disk corruption would
raw = bytearray(base64.urlsafe_b64decode(token))
raw[30] ^= 1
try:
cipher.decrypt(base64.urlsafe_b64encode(bytes(raw)))
except InvalidToken:
print("Integrity check failed: decryption refused")The first line prints True because the intact token decrypts back to the original label. After one bit of the ciphertext changes, the HMAC tag no longer matches, so decrypt raises InvalidToken and prints Integrity check failed: decryption refused without returning any altered data.
Data Security in Machine Learning#
AI systems add attack surfaces that ordinary databases do not have:
- Data poisoning: An attacker who can write to a dataset, a labeling queue, or a scraped web source inserts samples that make the trained model misbehave, often only when a hidden trigger appears.
- Unsafe model files: Checkpoints saved with Python's pickle can run arbitrary code when loaded. PyTorch 2.6 made
torch.loaddefault toweights_only=True, which refuses anything except tensors and simple types, and the safetensors format stores only tensors. - Membership inference attacks: Querying a trained model can reveal whether a specific record was in its training set, so weights trained on sensitive data need the same protection as the data.
- Prompt injection: Instructions hidden in documents or web pages can make an LLM application reveal data from its context or send it to an attacker through its tools.
- Shadow AI: Employees paste confidential data into AI tools that the organization has not approved, outside its access controls and logs.
Computer vision data raises the stakes because images of people, homes, vehicles, and patients often contain personal information. In healthcare, scans that US hospitals use for medical image analysis fall under the HIPAA Security Rule, which requires administrative, physical, and technical safeguards for electronic protected health information. Processing frames on the camera with edge AI keeps raw video off the network entirely, federated learning trains a shared model while each site keeps its data, and confidential AI runs training or inference on sensitive data inside encrypted hardware enclaves in the cloud. For datasets that must stay inside a company's network, the On Premise integration of Ultralytics Platform runs dataset ingest, previews, and training on the company's own computer: the worker mounts the dataset folder read-only and dials out over HTTPS without opening inbound ports, and the image pixels never reach Platform, which receives only labels, metrics, and the best checkpoint.
Data Security vs. Data Privacy#
Data privacy concerns whether personal data is collected, used, shared, and retained lawfully and as people were told, under laws such as the GDPR. Data security supplies the technical and organizational protections that privacy commitments depend on, and it covers all valuable data, including trade secrets, source code, and model weights that contain no personal information. Privacy-enhancing techniques such as differential privacy sit between the two by limiting what a released model or statistic reveals about any one person. A breach is a security failure that becomes a privacy incident when personal data is exposed: under GDPR Article 33, the controller has 72 hours from becoming aware of such a breach to notify its supervisory authority, unless the breach is unlikely to put people's rights and freedoms at risk.










