Skip to content
Back to Blog
·11 min read·compliance

PII in Logs: The DPDP Blind Spot in Indian Applications

PII in application logs is the DPDP Act blind spot most Indian firms overlook. Learn redaction, retention limits, and access controls that close the gap.

BR

Bachao.AI Research Team

Cybersecurity Research

Check DPDP Compliance

Compliance risk for Indian SMBs

Non-compliance with the DPDP Act 2023 carries penalties up to ₹250 crore. This post explains what's at stake and what action to take.

Application logs are the most overlooked PII store in most Indian companies. Under the DPDP Act 2023, log lines that capture Aadhaar-like identifiers, phone numbers, emails, or session tokens are "personal data" like any database column — subject to the same purpose limitation, retention limits, access control, and erasure obligations. Yet logs are almost never included in DPDP data-mapping exercises, which means the biggest leak surface in the stack is also the least governed.

Most teams instrument logging early, before anyone thinks about compliance, and the logging library serializes whatever it's handed — full payloads, headers, user objects — straight into a file, a log aggregator, or a third-party error tracker. Nobody revisits that decision when the DPDP Act arrives. This post covers why logs are a blind spot, redaction and structured-logging patterns, retention limits, access control on log platforms, and what an erasure request means for your log pipeline.

Why logs are a DPDP blind spot, not an edge case

Data protection programs in India tend to focus on obvious stores — the primary database, the CRM, backup snapshots. Logs get treated as operational telemetry, not personal data, because engineers see them as debugging artifacts rather than a data store. That framing is wrong under the DPDP Act's broad definition of personal data — any data "about" an identified or identifiable individual — broad enough to include an email address in a request log, a name in an error stack trace, or a masked-but-reversible phone number in an analytics event.

Three things make logs riskier than a database:

  1. Volume and velocity. A production system can emit millions of log lines a day; each is a potential PII exposure point no manual review can catch.
  2. Fan-out. The same log line is often shipped to multiple destinations at once — a local file, a log platform, an error tracker like Sentry, and an analytics pipeline — multiplying where that personal data now lives.
  3. Low observability of the leak itself. A misconfigured database column shows up in a schema review. A PII leak inside a logger.info() call three levels deep in a request handler usually doesn't surface until someone greps the logs for a phone number and finds it in a dozen places.
⚠️
WARNING
Full request/response logging — a common default in Express, Django, and Spring Boot middleware during development — is the single most common source of PII-in-logs. It's rarely turned off before production, because nobody owns that decision.

What PII ends up in logs

Walk a typical Indian fintech or healthtech request path and you'll find personal data leaking at every layer, not just the application code teams usually audit.

    1. Application logs: full request bodies with names, phone numbers, Aadhaar or PAN-like identifiers, and session tokens, often logged on error paths for debugging context.
    2. Access/web-server logs: query strings carrying tokens, OTPs, or user IDs get written verbatim by Nginx, Apache, or the load balancer's default log format.
    3. Error trackers: tools like Sentry or Bugsnag capture full exception context, including local variables and payloads, by default — often on infrastructure with weaker access controls than the production database.
    4. Analytics pipelines: click and event streams sent to product-analytics tools often include user identifiers, email, and free-text fields a support agent typed into a ticket.
The diagram below shows the difference between a naive log line and a redaction-aware pipeline.
graph TD A[Incoming request] --> B[Application handler] B --> C{Logging path} C --> D[Naive log line] D --> E[Full payload logged] E --> F[Aadhaar-like ID and token in plaintext] F --> G[Shipped to log platform] G --> H[PII now in 3+ systems] C --> I[Redaction middleware] I --> J[Structured log event] J --> K[Sensitive fields masked] K --> L[Safe log shipped] style A fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style B fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style C fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style D fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style E fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style F fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style G fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style H fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style I fill:#1e3d2f,stroke:#10B981,color:#e2e8f0 style J fill:#1e3d2f,stroke:#10B981,color:#e2e8f0 style K fill:#1e3d2f,stroke:#10B981,color:#e2e8f0 style L fill:#1e3d2f,stroke:#10B981,color:#e2e8f0

Redaction and structured-logging patterns

The fix isn't "stop logging" — teams need logs to debug incidents. The fix is making redaction structural, not a code-review checklist item skipped under deadline pressure.

Move from string logging to structured logging. Free-text log statements like logger.info("User " + user.email + " placed order " + order) are impossible to redact reliably because the PII is buried in unstructured text. Structured logging — a JSON object with named fields — lets a redaction layer inspect field names and apply rules.

Apply redaction at the logging middleware, not at each call site. Relying on every developer to remember to mask a field before calling logger.info() guarantees leaks; someone will forget, especially on error paths written in a hurry during an incident. A centralized serializer that scrubs known-sensitive field names (aadhaar, pan, password, token, otp, authorization) before anything is written closes that gap structurally.

Use allow-lists for error trackers, not deny-lists. Error-tracking SDKs default to capturing everything in scope for maximum debuggability. Configure them to send only an explicit, reviewed set of fields — a deny-list breaks the first time someone adds a new field to a request object.

Mask, don't just truncate. Partial masking (98XXXXXX10) is far more useful for debugging than either full plaintext or a fully redacted [REDACTED] token, while still reducing identifiability.

🛡️
SECURITY
Tokens, session cookies, and OTPs are more dangerous in logs than most PII fields, because they enable direct account takeover, not just identity exposure. Treat them as a P0 redaction target before Aadhaar-like fields.

Know your vulnerabilities before attackers do

Run a free VAPT scan — takes 5 minutes, no signup required.

Book Your Free Scan

Retention limits on logs

The DPDP Act's storage-limitation principle applies to logs like any other personal-data store: don't retain data longer than necessary for the purpose it was collected for. In practice, most companies never set an explicit retention policy on logs — they accumulate indefinitely because nobody actively decides to delete them, and log platforms default to "keep everything" unless configured otherwise.

A defensible retention posture separates logs by purpose:

Log categoryTypical justified retentionContains PII
Security/audit logs (auth events, access logs)At least 1 year (DPDP Rules 2025, Rule 6 floor); longer if needed for regulatory purposesOften yes — user IDs, IPs
Application debug logsShort, days to a few weeksFrequently yes, if unredacted
Error-tracker eventsShort to moderate, tied to triage windowOften yes by default
Analytics/product eventsDefined by product need, should be reviewedSometimes, depends on fields sent
One exception cuts against that general rule: the DPDP Rules, 2025 set a floor for security and access logs, requiring at least one year of retention to support detecting, investigating, and remediating unauthorized access (Rule 6, MeitY). That floor doesn't extend to debug logs or analytics events, which stay governed by the storage-limitation principle above. Either way, a retention decision needs to exist for every category and be enforced by automated deletion, not left to storage-cost pressure to eventually force a cleanup.
₹250 croreMaximum penalty magnitude for failure to implement reasonable security safeguards under the DPDP Act (MeitY, DPDP Act 2023)

Access control on log platforms

Log platforms are frequently under-governed relative to the production database that generated the data. It's common for half the engineering org to have broad read access to a centralized logging tool — an ELK stack or a SaaS log platform — when only on-call and platform teams genuinely need it.

💡
TIP
Treat your log platform's access list with the same rigor as your production database's IAM policy. If an engineer can't query the customer table directly, they shouldn't be able to grep that customer's data out of a log stream either.

Baseline controls worth enforcing:

    1. Role-based access scoped to the minimum team that needs it (on-call, platform engineering, security).
    2. Separate, more restrictive access for any log stream that hasn't been redaction-verified.
    3. Logging and alerting on who queried the log platform and what they searched for — logs about logs, so misuse is detectable.
    4. SSO and MFA enforced on the log platform itself, not just the application it monitors.

What an erasure request means for your log pipeline

A data principal erasure request under the DPDP Act asks a company to delete that person's data once the processing purpose is fulfilled or consent is withdrawn (subject to legal retention exceptions). Most companies can execute this against their primary database — but logs are the part of the pipeline erasure requests routinely miss, because nobody maps them as a personal-data location during request fulfillment. A company can delete a user's row, confirm the deletion, and still have that user's phone number and order history sitting in months of unredacted logs, an error tracker, and an analytics warehouse.

Practical steps to close this:

  1. Include log platforms and error trackers in your data-mapping inventory alongside the primary database and backups.
  2. Redact at write-time so there's nothing to erase later. If PII never reaches long-retention log storage in plaintext, erasure requests against logs become largely moot for those fields.
  3. For fields logged in identifiable form for security/audit purposes, tie retention to a defined window and automate deletion, rather than relying on a manual erasure-request trigger.
  4. Document the exception where logs are retained past a deletion request for legitimate security or legal-obligation purposes — the DPDP Act permits this, but the exception needs to be recorded, not assumed.
🎯Key Takeaway
Logs are personal data under the DPDP Act, and they're usually the least governed data store in the company. Redact PII at the logging middleware, not at individual call sites; apply real retention limits; lock down log-platform access the way you'd lock down the production database; and make sure logs are in your data-mapping inventory before an erasure request or a security audit finds them for you.

Where personal data typically leaks in a logging stack

pie title Where PII typically leaks in a logging stack "Application logs" : 40 "Access and web server logs" : 20 "Error trackers" : 25 "Analytics pipelines" : 15

A practical checklist to close the gap

🚨
DANGER
If your incident-response runbook says "check the logs" as the first debugging step, and your logs are unredacted, every incident investigation is itself a PII exposure event involving whoever is on that call.

Use this as a starting audit for any Indian application handling personal data:

    1. Grep production log samples for common PII patterns (phone numbers, email formats, Aadhaar-like sequences) to establish a baseline.
    2. Move from string-concatenated logging to structured JSON logging with a shared serializer.
    3. Configure a redaction layer at the logging framework level, covering known sensitive field names.
    4. Configure error trackers to use field allow-lists, not defaults.
    5. Set explicit, automated retention windows per log category, differentiated for security/audit versus debug logs.
    6. Restrict log platform access with role-based permissions and log the access itself.
    7. Add log platforms and error trackers to your DPDP data-mapping inventory and erasure-request runbook.
Frameworks like the OWASP Logging Cheat Sheet and NIST's guidance on log management both treat sensitive-data handling in logs as a first-class control — worth using alongside DPDP-specific guidance from MeitY when building redaction rules.

Getting this right is rarely a rewrite — it's a middleware change, a retention policy, and an access-control review. Our automated VAPT platform, built by Dhisattva AI Pvt Ltd, includes checks for common log-exposure patterns as part of a broader DPDP-readiness assessment, and — where formal empanelled assessment is required — this is delivered with a CERT-In empanelled partner. Start with a free VAPT scan, read more on the Bachao.AI blog, or see the full program at /dpdp-compliance.

Frequently Asked Questions

Are application logs considered personal data under the DPDP Act?
Yes. Any log line that identifies a person — a name, phone number, email, session token, or Aadhaar-like identifier — is personal data under the DPDP Act's broad definition, subject to the same purpose limitation, security, and erasure obligations as data in a primary database.
How long should we retain application logs to stay compliant?
For security and access logs, the DPDP Rules, 2025 set a floor: at least one year of retention (Rule 6) to support detecting and investigating unauthorized access. For application debug logs and analytics events, the Act's storage-limitation principle applies instead — don't retain longer than necessary for the purpose. Automate deletion for both categories rather than letting logs accumulate indefinitely.
Does deleting a user from our database satisfy an erasure request if their data is still in our logs?
Not fully. If unredacted personal data remains in logs, error trackers, or analytics pipelines, the erasure obligation hasn't been genuinely fulfilled for those copies. Logs need to be part of your data-mapping and erasure-request workflow, not just the primary database.
What's the fastest way to reduce PII exposure in logs without a major rewrite?
Add a redaction layer at the logging middleware or serializer level that masks known-sensitive field names before anything is written. This closes the gap structurally, without requiring every developer to redact at each call site.
Are error-tracking tools like Sentry a DPDP risk even if we don't log PII ourselves?
Yes. Error trackers capture full exception context, including request payloads and local variables, by default — often including personal data the application code never explicitly logged. Configuring an allow-list of captured fields avoids this becoming an uncontrolled PII store.
Who should have access to our centralized log platform?
Access should be role-based and limited to the team that genuinely needs it — on-call, platform engineering, security — the same discipline applied to production database access. Broad, unaudited read access across engineering is one of the most common log-governance gaps.
BR

Bachao.AI Research Team

Cybersecurity Research

AI-powered security research and threat intelligence from the Bachao.AI team. Covering the latest vulnerabilities, CVEs, and cybersecurity developments affecting Indian businesses.

Get cybersecurity insights for Indian SMBs

Weekly vulnerability alerts, DPDP compliance tips, and security guides. No spam — unsubscribe anytime.

We respect your privacy. Your email is never shared.

See where your business stands against the DPDP Act 2023

Free automated scan — risk score in under 2 hours. No credit card required.

Check DPDP Compliance
Find your vulnerabilitiesStart free scan →