AI Assistants Reading Account Data: Read-Only Architecture and Privacy Protection Practices

    This article explores the architecture and privacy practices for integrating Large Language Models (LLMs) into consumer finance scenarios. It covers key technical decisions including separating read-only queries from write operations, implementing delegated authorization without handling user credentials, applying the principle of least privilege for data scope control, delegating deterministic calculations to code rather than the model, and managing the data lifecycle. A pre-launch security checklist is also provided to ensure robust compliance and data protection.

    1. Scenario Background and Technical Positioning

    As Large Language Models enter consumer finance scenarios, the core user need is direct: querying income and expenses via natural language without switching between multiple banking apps. From an engineering perspective, this involves three stages: account data acquisition, data understanding and calculation, and result presentation. Each stage has its own security boundaries that must be designed and handled separately.

    The value of this feature lies in reducing information retrieval costs, but the risk is concentrated in the same place. Account data is highly sensitive, model outputs may contain errors, and excessive authorization can lead to irreversible leaks or misoperations. Therefore, the first step in solution design is to clearly define what the system can and cannot do, and then design permissions, data flows, and audit mechanisms around these boundaries.

    2. Defining Boundaries First: Separating Read-Only Queries from Write Operations

    Read-only design is the most critical architectural decision. The system is only responsible for reading and analyzing data; it does not initiate transfers, modify account statuses, or proxy investment operations. This division offers three main benefits:

    • Even if the model misunderstands or outputs an error, the system cannot cause fund movements.
    • The permission list is simple, and the scope of security audits can be accurately defined.
    • The difficulty of compliance assessment is significantly reduced, as the system is not a transaction execution entity.

    If write operations are needed in the future, they should use independent services, independent authorization scopes, and independent manual confirmation steps. It is not recommended to gradually expand existing permissions within the same session, as this blurs the permission boundary and makes it difficult to trace the authorization source of a specific operation.

    3. Authorization Flow: The Application Does Not Touch User Credentials

    The standard approach for account integration is delegated authorization. Users complete authentication on their bank’s or a designated data aggregation service’s page, and the application only receives a time-limited access token, never touching the user’s login password. A typical flow is as follows:

    1. The application initiates an authorization request and declares the required permission scope.
    2. The user logs in on a trusted page and confirms the authorization content.
    3. The authorization service returns an authorization code, which the application exchanges for an access token.
    4. The token is stored in a server-side key management system and updated via a refresh mechanism before expiration.
    5. The user can revoke authorization at any time; the token is immediately invalidated, and the application must stop reading data.

    At the implementation level, there are several baseline requirements: the application must not save bank passwords; tokens must not appear in logs, error messages, or frontend code; and callback addresses must be validated against a whitelist. Below is a sample code snippet showing the minimal parameter construction for an authorization request:

    1. REQUESTED_SCOPES = ["accounts:read", "transactions:read"]
    2. def build_consent_request(user_id: str) -> dict:
    3. # Only declare the permission scopes necessary for querying; do not request write permissions
    4. return {
    5. "user_id": user_id,
    6. "scopes": REQUESTED_SCOPES,
    7. "redirect_uri": "https://your-app.example/callback",
    8. "state": new_random_state(), # Random value to prevent cross-site request forgery (CSRF)
    9. }

    The permission names and functions in the above code are illustrative; actual fields should refer to the official documentation of the data service used.

    4. Data Scope Control: Following the Principle of Least Privilege

    After authorization is granted, the data scope the application receives still needs to be manually restricted. Common data categories include account name, account type, last four digits of the account number, balance, credit limit, and transaction details. Full account numbers, ID information, and contact information are irrelevant to most analysis scenarios and should not be obtained or stored.

    The time span of transaction records requires a trade-off between analysis effectiveness and exposure. A longer span yields more accurate periodic billing and trend judgments, but a leak would expose more historical data. A safer approach is to set a default window, such as the past 90 days, expanding only when the user explicitly requests a longer period, and explaining the implications of the expansion in the UI.

    The following sample code completes field filtering and masking before data enters the business layer:

    1. ALLOWED_FIELDS = {"account_name", "account_type", "masked_number", "balance", "transactions"}
    2. def sanitize_account(raw: dict) -> dict:
    3. # Keep only business-essential fields; keep only the last four digits of the account number
    4. cleaned = {k: v for k, v in raw.items() if k in ALLOWED_FIELDS}
    5. if "masked_number" in cleaned:
    6. cleaned["masked_number"] = str(cleaned["masked_number"])[-4:]
    7. return cleaned

    Filtering should be completed at the very front-end of data integration, rather than relying on the model to “ignore” unneeded content. Once the model comes into contact with sensitive fields, it may repeat them in its output or be manipulated by prompt injection to leak them.

    5. Layered Processing: Code for Calculation, Model for Expression

    In the analysis phase, a common misconception is letting the model directly perform all numerical calculations. Large Language Models excel at understanding questions and organizing language, but they are unreliable for summing large batches of numbers, category aggregations, and cross-account reconciliations. A more robust division of labor is:

    • Deterministic code handles summarization, categorization, variance calculation, and periodic statistics.
    • The model is responsible for understanding user questions, selecting appropriate calculation functions, and explaining the results in natural language.
    • Each conclusion includes data source, time range, and calculation basis for easy user verification.

    The sample code below shows calculation logic handled entirely by code:

    1. from collections import defaultdict
    2. def summarize_spending(transactions: list[dict]) -> dict:
    3. totals = defaultdict(float)
    4. for tx in transactions:
    5. if tx["amount"] < 0: # Assume negative numbers represent expenses
    6. totals[tx["category"]] += -tx["amount"]
    7. return {"by_category": dict(totals), "total": round(sum(totals.values()), 2)}

    For anomaly detection, such as duplicate deductions or a sudden increase in periodic billing, the system should use phrasing like “suspected” or “recommended to verify” rather than direct assertions. Detection rules should be explainable and allow users to flag false positives for continuous correction.

    When professional terms are involved, the system should explain the concept before providing the calculation result. For example, when answering questions related to the annual percentage rate (APR), it should explain the interest calculation method, provide an estimated interest expense, and note the estimation assumptions.

    6. Privacy Isolation and Data Lifecycle

    Privacy processing for financial data needs to be designed at the architectural level, not just relying on a privacy statement. The following are basic requirements:

    1. Sessions within the dedicated feature area use different storage and logging strategies than general sessions to prevent data intermingling.
    2. Clearly inform users whether data is used for model training, and technically isolate it through data tagging or independent pipelines.
    3. Set data retention periods and automatically clean up cached transaction data and analysis results upon expiration.
    4. After a user unbinds an account, relevant tokens and caches should be synchronously deleted or invalidated, with a clear statement of the completion time.
    5. Amounts, account names, and transaction summaries in logs must be masked; only request IDs and error types should be recorded.

    Each stage of the data lifecycle should have a designated owner and audit records. Without these records, it is difficult to locate which stage caused an exposure when a problem occurs.

    7. Pre-Launch Security Checklist

    Before solution review or launch, you can check the following items one by one:

    • Does the permission scope include only read permissions, and do they correspond one-to-one with product features?
    • Has the application never touched user passwords, and are tokens stored only in a server-side key management system?
    • Are callback addresses validated against a whitelist, and do authorization requests include anti-forgery parameters?
    • Does the data integration layer complete field filtering, and are full account numbers and ID information excluded?
    • Is there a default value for the transaction query time window, and does expansion require explicit user action?
    • Are numerical calculations like summarization and categorization performed by deterministic code, with verifiable calculation bases retained?
    • Does the output include a disclaimer advising users to rely on the original bank or billing information?
    • Is the data in the dedicated feature area isolated from general data, and is there a clear statement and technical constraint regarding training use?
    • After a user revokes authorization, are tokens and caches invalidated within the agreed time, with audit records available for review?
    • Are logs masked, and is there any path that mistakenly prints sensitive fields into error messages?

    Completing this checklist allows the team to clearly explain the system’s permission boundaries, data flows, and division of responsibilities, and provides verifiable evidence when users raise questions.