Skip to main content

threat-model

BitKa Threat Model

  • Application Version: 28/11/2025
  • Description: A microservice-based digital wallet and trading platform that provides secure custodial account management, real-time market data access, and a verifiable off-chain ledger. The platform enables users to register and authenticate, manage profiles, deposit tokens, transfer funds, place trade orders, and initiate withdrawals signed by custody-controlled keys. It incorporates durable asynchronous processing for transactional correctness, integrates with Mailgun and GCS, authenticates internal services through a layered trust model, and maintains operational readiness through CI/CD and comprehensive audit logs.
  • Document Owner: Thanisara Satalalai

External Dependencies

External dependencies are items outside of the application code.

IDDescription
1Bitka and its database on premise instance is running on a Linux server running Ubuntu.
2Bitka and its database on cloud instance is running on a Google Compute Engine on Google Cloud Platform.
3BitKa's cloud storage is on Google Cloud Storage.
4MailGun is used to send out notifications to users.

Entry Points

Entry points are the interfaces in which the user can feed data into the system.

IDNameDescriptionTrust Levels
1HTTPS portThe primary public network port.(4) Application layer services
1.1User UIFront-end web interface delivered via HTTPS. It is the primary entry point for end-users and initiates all user-driven workflows.(4) Application layer services
1.1.1Log in pagePublic interface that collects user credentials and initiates authentication flows.(2) Anonymous user
1.1.2Registration pagePublic interface allowing new users to create new accounts.(2) Anonymous user
1.1.3Account pageAuthenticated user interface detailing account information.(2) Anonymous user
1.1.3.1Account page: Profile setupFirst-time profile configuration after registration, where users enter initial identity details.(3) Authorize user
1.1.3.2Account page: Profile settingPage allowing users to modify their profile details and preferences after initial setup.(3) Authorize user
1.1.4Transaction pagePage that enables users to initiate transfer and view transfer history.(3) Authorize user
1.1.4.1Transaction page: Transfer placingUser interface for initiating transfer within the system.(3) Authorize user
1.1.4.2Transaction page: Transfer confirmationDisplays transaction summary for user to verify prior to execution.(3) Authorize user
1.1.4.3Transaction page: Transfer successConfirmation screen displaying status of successful transfer.(3) Authorize user
1.1.5Withdraw pagePage that enables users to initiate withdrawal.(3) Authorize user
1.1.5.1Withdraw page: Withdraw confirmationDisplays withdraw summary for user to verify prior to execution.(3) Authorize user
1.1.5.2Withdraw page: Withdraw successConfirmation screen displaying status of successful withdrawal.(3) Authorize user
1.1.6Trade pageUser interface for displaying market data and placing markets and limited trade orders.(3) Authorize user
1.1.6.1Trade page: MainLanding page displaying market data, order forms, and trade history.(3) Authorize user
1.1.6.2Trade page: Limited buyInterface for placing buy orders with specified price and quantity.(3) Authorize user
1.1.6.3Trade page: Limited sellInterface for placing sell orders with specified price and quantity.(3) Authorize user
1.1.6.4Trade page: Market buyInterface enabling instant market buy orders.(3) Authorize user
1.1.6.5Trade page: Market sellInterface enabling instant market sell orders.(3) Authorize user
2API endpointsinternal entry points(4) Application layer services
2.1Authentication serviceall authentication operations(4) Application layer services
2.1.1POST https://api.bitka.polishstack.com/v1/auth/loginLogin(2) Anonymous user
2.1.2POST https://api.bitka.polishstack.com/v1/auth/registerRegister(2) Anonymous user
2.1.3POST https://api.bitka.polishstack.com/v1/auth/refreshRefresh access token(3) Authorize user
2.1.4POST https://api.bitka.polishstack.com/v1/auth/logoutLogout(3) Authorize user
2.1.5GET https://api.bitka.polishstack.com/v1/.well-known/jwks.jsonJWKS (JSON Web Key Set)(2) Anonymous user
2.2User serviceProvides access to user data, profile management, and security management.(4) Application layer services
2.2.1GET https://api.bitka.polishstack.com/v1/users/meGet current user profile.(3) Authorize user
2.2.2PATCH https://api.bitka.polishstack.com/v1/users/meUpdate current user profile.(3) Authorize user
2.2.3GET https://api.bitka.polishstack.com/v1/users/:idGet user profile by ID.(3) Authorize user
2.2.4POST https://api.bitka.polishstack.com/v1/users/me/change-passwordChange password for the authenticated user.(3) Authorize user
2.3Ledger serviceHandles account balances, transactions and histories.(4) Application layer services
2.3.1GET https://api.bitka.polishstack.com/v1/ledger/accountsList ledger accounts.(3) Authorize user
2.3.2GET https://api.bitka.polishstack.com/v1/ledger/accounts/:account_idGet ledger account by id.(3) Authorize user
2.3.3GET https://api.bitka.polishstack.com/v1/ledger/transactionsList transactions.(3) Authorize user
2.3.4POST https://api.bitka.polishstack.com/v1/ledger/transactionsCreate a transaction (debit/credit/transfer).(3) Authorize user
2.3.5GET https://api.bitka.polishstack.com/v1/ledger/transactions/:transaction_idGet transaction by id.(3) Authorize user
2.4Order serviceManages trade order creation, querying, and lifecycle operations.(4) Application layer services
2.4.1POST https://api.bitka.polishstack.com/v1/ordersCreate order.(3) Authorize user
2.4.2GET https://api.bitka.polishstack.com/v1/ordersList orders (filterable).(3) Authorize user
2.4.3GET https://api.bitka.polishstack.com/v1/orders/:order_idGet order by id.(3) Authorize user
2.4.4DELETE https://api.bitka.polishstack.com/v1/orders/:order_idCancel order by id.(3) Authorize user
2.5Market data serviceProvides market-related information such price data, order books, and real-time feeds.(4) Application layer services
2.5.1GET https://api.bitka.polishstack.com/v1/marketdata/symbolsList available symbols (market pairs).(3) Authorize user
2.5.2GET https://api.bitka.polishstack.com/v1/marketdata/candlesGet candles (OHLCV) for a symbol and interval (historical).(3) Authorize user
2.5.3GET https://api.bitka.polishstack.com/v1/marketdata/ticksGet trades (ticks) for a symbol (historical).(3) Authorize user
2.5.4GET https://api.bitka.polishstack.com/v1/marketdata/orderbook/:symbolOrderbook snapshot (top N) for a symbol.(3) Authorize user
2.5.5GET https://api.bitka.polishstack.com/v1/marketdata/orderbook/:symbol/historyHistorical orderbook deltas/snapshots for reconciliation.(3) Authorize user
2.5.6GET https://api.bitka.polishstack.com/v1/marketdata/streamReal-time streaming info (WebSocket).(3) Authorize user
3Third party entry pointsEntry points for external, non user services.(1) External services
3.1MailgunExternal system used for delivering subscription emails.(1) External services
3.2Cloudflare R2/GCSExternal object storage used for storing avatar, token icon, or other static files.(1) External services

🛡️ Assets

Assets are valuable things that need to be kept safe.

IDNameDescriptionTrust Levels
1UserAssets related to users.(2) Anonymous user
1.1User credentialsUser's username and password.(3) Authorize user
1.2JWTToken generated when user logs in, used to verify identity when user tries to access protected resource.(4) Application layer services
1.2.1Access tokenProves identity for short periods.(4) Application layer services
1.2.2Refresh tokenUsed to obtain new access tokens.(3) Authorize user
1.2.3Public keyPublic keys for token verification.(2) Anonymous user
1.2.4Private keySecret key for signing JWTS.(5) Internal services
1.3User dataAny personal or account-related data the application stores about a user.(3) Authorize user
2ServiceAssets related to application and backend services.(5) Internal services
2.1Site AvailabilityBitka should always be available and all of its services should be working as intended.(5) Internal services
3InfrastructureAssets related to platform and deployment environment.(5) Internal services
3.1DatabasePostgreSQL that stores service data.(5) Internal services
3.2TLS CertificatesUsed to secure all communications between User UI and internal server.(5) Internal services
3.3Secret assetsAdmin user credentials, database password, env files.(6) Admin

Trust Level Definitions

IDNameDescription
1External servicesThird party services that interact with services.
2Anonymous userUser who has accessed the site but has yet to log in.
3Authorize userUser who has logged in to the site with valid credentials.
4Application layer servicesServices that face the outside system and receive public input.
5Internal servicesService that only communicates with internal system.
6AdminUser with full privilege to manage website, services, and database.

Data Flow Diagram

Level 0 Data Flow Diagram

Level 0 Data Flow Diagram

Level 1 Data Flow Diagram

Level 1 Data Flow Diagram


STRIDE Threat Lists and Mitigation

Spoofing

IDComponent InvolvedEntry PointTarget AssetDescriptionMitigation Ideas
1User/P11.1.1 Log in page (UI), 2.1.1 POST /auth/login1.1 User credentials, 1.2 JWTAn attacker spoofs a legitimate User to gain unauthorized access to the application.Implement MFA.
2P22. API endpoints (Internal Calls)2. Service, 1.2.4 Private keyAn attacker spoofs P2 to trick other services into accepting unauthorized requests.Authenticate interservice communication.
3MailGun/P83.1 Mailgun2. Service, 3.3 Secret assetsAn attacker spoofs Mailgun to send fake emails to the user or send fake confirmation status back to P8.Clear communication with users when a third party service is compromised. Audit actions done by third party services.

Tampering

IDComponent InvolvedEntry PointTarget AssetThreat DescriptionMitigation Ideas
1Data Flows (In Transit)1. HTTPS port, 2. API endpoints1.3 User data, 1.2 JWTAn attacker modifies data being passed between services.Authenticate interservice communication.
2D1/D2All POST/PATCH endpoints3.1 Database, 1.3 User dataAn attacker directly modifies account records, orders/trades, or static assets in the data stores.Utilized principle of least privilege for accounts accessing the database.
3P92. API endpoints (Internal Calls)2. Service, 1.3 User dataAn attacker injects or modifies events in the stream.Input authentication for data going to P9 service.

Repudiation

IDComponent InvolvedEntry PointTarget AssetThreat DescriptionMitigation Ideas
1P41.1.6.2-5 Trade page, 2.3.4 POST /ledger/transactions, 2.4.1 POST /orders1.3 User data, 3.1 DatabaseA user places an order but later denies placing it.Log all actions done by users.

Information disclosure

IDComponent InvolvedEntry PointTarget AssetThreat DescriptionMitigation Ideas
1D1All GET endpoints3.1 Database, 1.1 User credentials, 1.3 User dataSensitive data is leaked from the database.Data encryption, strict access control lists and network segregation.
2Data Flows (In Transit)1. HTTPS port, 2. API endpoints1.1 User credentials, 1.3 User dataSensitive data is intercepted.Ensure TLS is used end-to-end. Avoid logging sensitive data in plain text.

Denial of service

IDComponent InvolvedEntry PointTarget AssetThreat DescriptionMitigation Ideas
1P1/P21. HTTPS port, 2.1.1 POST /auth/login2.1 Availability of the siteAn attacker floods the public endpoints with requests.Rate limiting on public APIs. Implement DDoS mitigation services.
2P4/P7All authorized user endpoints2.1 Availability of the siteAn attacker floods authorised user services with requests.Rate limit user on service user/api calls.
3D1All GET/POST endpoints3.1 Database, 2.1 Availability of the siteThe database is overwhelmed by too many read/write requests from the services.Proper indexing and query optimization.

Elevation of privilege

IDComponent InvolvedEntry PointTarget AssetThreat DescriptionMitigation Ideas
1P1/P2All authorized user endpoints1.3 User data, 6. AdminAn attacker with a basic user account exploits a vulnerability to gain administrator privileges.Role-Based Access Control, Input validation and principle of least privilege.
2Inter-Service Flows2. API endpoints (Internal Calls)2. Service, 3.3 Secret assetsA compromised service uses its internal credentials to perform actions it shouldn't.Authenticate interservice communication.