Service Dependency Graph

Cyber Anomaly Detection & Dependency Risk: Markov transition matrix, PageRank, and single-point-of-failure analysis

Why a dependency layer

The detector on the Detector page scores each host’s activity in 5-minute windows. It says nothing about what happens if the security team responds by isolating that host. Isolating a host that many other services depend on can cause an outage that does more damage than the attack. This page builds the structural layer that answers that question. It ranks services by how much of the enterprise depends on them. The ranking feeds a containment rule on the Evaluation page: alerts on the most critical services go to a human before any automated isolation.

The graph is simulated: 23 services and 42 dependencies, with call volumes drawn from a log-normal distribution. A real deployment would build it from service-mesh or API-gateway call logs.

Definitions

Edge direction. An edge \(i \to j\) means service \(i\) calls (depends on) service \(j\). The edge weight \(w_{ij}\) is the call volume over a fixed period.

Markov transition matrix. Follow one request as it moves from service to service. The probability that the next call goes to \(j\), given that the request is at \(i\), is

\[P_{ij} = \Pr(X_{t+1} = j \mid X_t = i) = \frac{w_{ij}}{\sum_k w_{ik}},\]

so every row of \(P\) sums to 1 (row-stochastic). Services that call nothing (for example the key-management service) are dangling. Their rows are set to \(1/n\), the standard convention: a request that reaches a dead end restarts anywhere.

The Markov (memoryless) assumption. The next hop depends only on the current service, not on how the request got there. Real request paths are often session-dependent (authentication, then API, then database), so this is an approximation. With real call traces it can be tested by comparing the fit of first- and second-order transition models. This simulation has no traces, so the assumption is stated, not tested.

PageRank. PageRank is the stationary distribution \(\pi\) of the walk with random restarts:

\[\pi = \alpha\, \pi P + \frac{1-\alpha}{n}\mathbf{1}^\top .\]

\(\pi_j\) is the long-run share of request hops that land on service \(j\). We call this dependency concentration. It is not the probability that a failure spreads to \(j\), and it does not detect single points of failure by itself. The damping factor \(\alpha\) is the chance the walk follows a call rather than restarting. The value \(\alpha = 0.85\) is a web-search convention, not a risk parameter, so we test how sensitive the ranking is to it.

Single points of failure are a connectivity question, so we measure them directly:

  • Articulation points: services whose removal disconnects the graph (treating edges as undirected).
  • Betweenness: how many shortest dependency paths pass through a service.
  • Removal impact: remove the service and count the share of the other services that can no longer reach at least one dependency they could reach before.

Computation

Display code
pr <- graph$pagerank
tibble(
  check = c(
    "Rows of P sum to 1 (max deviation)",
    "Power-iteration steps to converge",
    "L1 change at last step (tolerance)",
    "Max difference vs igraph::page_rank()"
  ),
  value = c(
    format(max(abs(rowSums(graph$P) - 1)), digits = 2),
    as.character(pr$iterations),
    sprintf("%s (%s)", format(pr$l1_change, digits = 2), format(cfg$graph$tol)),
    format(graph$max_diff_vs_igraph, digits = 2)
  )
)
check value
Rows of P sum to 1 (max deviation) 4.4e-16
Power-iteration steps to converge 39
L1 change at last step (tolerance) 6.3e-13 (1e-12)
Max difference vs igraph::page_rank() 9.6e-14

How to read the table. Each row is a check that the calculation behaved as intended. The first confirms every row of the transition matrix sums to one, so each service’s outgoing calls form a proper probability split. The second and third show how many repeated passes the ranking needed before it stopped changing, and how small the last change was. The final row compares our hand-written ranking with igraph, a widely used network-analysis library.

What the table tells you. The calculation is sound. The row sums are exact to rounding error, the ranking settled after 39 passes, and the result agrees with igraph to within 1e-13, which is effectively identical. That matters because the criticality tiers that govern containment decisions rest on these numbers. An error here would silently route the wrong alerts to automation instead of to a person, and nothing downstream would reveal it.

Damping sensitivity. Re-ranking the services at \(\alpha \in \{0.75, 0.85, 0.95\}\) gives a Kendall rank correlation with the \(\alpha = 0.85\) ranking of at least 1.000. On this graph the ranking does not depend on the damping choice, although the PageRank values themselves do.

Dependency map

The map shows which services the rest of the enterprise funnels into. A security response that isolates one of these services can take down everything upstream of it.

Display code
set.seed(cfg$graph$seed)
ggraph(g, layout = "sugiyama") +
  geom_edge_link(
    aes(width = calls), alpha = 0.35, colour = "#52514e",
    arrow = arrow(length = unit(2.5, "mm"), type = "closed"),
    end_cap = circle(4, "mm")
  ) +
  geom_node_point(aes(size = pagerank, colour = tier)) +
  geom_node_text(aes(label = name), size = 3.4, repel = TRUE, colour = "#0b0b0b",
                 bg.colour = "white", bg.r = 0.15, point.padding = unit(3, "mm")) +
  scale_edge_width(range = c(0.3, 2), name = "Call volume") +
  scale_size_area(max_size = 14, name = "PageRank") +
  scale_colour_manual(values = tier_colors, name = "Criticality tier") +
  guides(colour = guide_legend(override.aes = list(size = 5))) +
  labs(
    title = "Simulated Service Dependency Graph",
    subtitle = "Arrows point from caller to dependency; node size = PageRank (dependency concentration)"
  ) +
  theme_void(base_size = 12) +
  theme(legend.position = "bottom", legend.box = "vertical", plot.title = element_text(face = "bold"),
        plot.margin = margin(5, 10, 5, 10))
Figure 1

How to read the plot. Each dot is a service, and each arrow points from a service to something it depends on: the caller sits at the tail, the dependency at the head. Entry points such as the web portal and mobile app sit at the top, and shared platform services sit at the bottom. Larger dots carry more request traffic in the long run (PageRank), thicker arrows carry more calls, and colour shows the criticality tier assigned further down the page.

What the plot tells you. Traffic converges on a handful of shared platform services: Key Management, File Store, DNS Resolver have the highest PageRank. Nobody uses these services directly, so they are easy to overlook, yet nearly everything else depends on them. Isolating one in response to an alert could take down much of the estate. The two articulation points, API Gateway and Customer Service, matter for a different reason: removing either splits the map into disconnected pieces.

Criticality ranking

The table compares the centrality measures side by side, so the containment rule rests on more than one measure.

Display code
gt_tab |>
  mutate(rank = row_number(), articulation_point = if_else(articulation_point, "Yes", "No")) |>
  select(rank, name, layer, pagerank, betweenness, articulation_point, removal_impact, criticality_tier) |>
  gt() |>
  tab_header(
    title = "Service Criticality Ranking",
    subtitle = "Sorted by PageRank; tiers combine connectivity and removal impact"
  ) |>
  cols_label(
    rank = "Rank", name = "Service", layer = "Layer", pagerank = "PageRank",
    betweenness = "Betweenness", articulation_point = "Articulation point",
    removal_impact = "Removal impact", criticality_tier = "Tier"
  ) |>
  fmt_number(pagerank, decimals = 3) |>
  fmt_number(betweenness, decimals = 1) |>
  fmt_percent(removal_impact, decimals = 0) |>
  tab_options(table.font.size = 12)
Table 1
Service Criticality Ranking
Sorted by PageRank; tiers combine connectivity and removal impact
Rank Service Layer PageRank Betweenness Articulation point Removal impact Tier
1 Key Management Platform 0.200 0.0 No 77% Tier 1
2 File Store Data store 0.099 4.0 No 59% Tier 1
3 DNS Resolver Platform 0.080 0.0 No 55% Tier 1
4 API Gateway Edge & identity 0.061 46.3 Yes 14% Tier 1
5 Notification Svc Business service 0.055 7.0 No 50% Tier 1
6 SIEM Logging Platform 0.044 4.3 No 36% Tier 2
7 Data Warehouse Data store 0.042 5.0 No 41% Tier 2
8 Cache Platform 0.039 0.0 No 36% Tier 2
9 Identity Provider Edge & identity 0.034 19.7 No 32% Tier 2
10 Orders DB Data store 0.033 0.5 No 23% Tier 2
11 Message Queue Platform 0.033 14.0 No 32% Tier 2
12 Orders Service Business service 0.031 6.0 No 18% Tier 2
13 Auth Service Edge & identity 0.029 13.0 No 27% Tier 3
14 Payments Service Business service 0.027 13.5 No 23% Tier 3
15 Customer DB Data store 0.024 1.0 No 27% Tier 3
16 Customer Service Business service 0.024 15.0 Yes 23% Tier 1
17 MFA Service Edge & identity 0.023 6.0 No 36% Tier 3
18 SaaS CRM External SaaS 0.023 0.0 No 27% Tier 3
19 Reporting Service Business service 0.021 5.7 No 18% Tier 3
20 Payments DB Data store 0.020 0.0 No 27% Tier 3
21 Web Portal Entry point 0.019 0.0 No 0% Tier 3
22 Mobile App Entry point 0.019 0.0 No 0% Tier 3
23 Partner API Entry point 0.019 0.0 No 0% Tier 3

How to read the table. Each row is a service, sorted by PageRank, its long-run share of request traffic. Betweenness counts how many shortest dependency paths pass through the service. An articulation point is a service whose loss splits the map in two. Removal impact is the share of all other services that lose access to something they need when this one goes down. Tier is the criticality class built from these measures and used by the containment rule below.

What the table tells you. The measures disagree, so no single one is enough. PageRank tracks removal impact reasonably well (rank correlation 0.73), while betweenness does not (-0.03): shared back-end services score zero betweenness yet cut off most of the estate when removed. Neither articulation point leads the PageRank list. PageRank is a useful first screen for dependency concentration, but containment rules should rest on the combined tiers, not on any single score.

Criticality tiers and the containment rule

The tiers are a policy choice built from the measures above:

  • Tier 1: an articulation point, or removal cuts off at least 50% of the other services. This gives 6 services: Key Management, File Store, DNS Resolver, API Gateway, Notification Svc, Customer Service.
  • Tier 2: PageRank at or above the median, and not Tier 1 (7 services).
  • Tier 3: everything else (10 services).

Containment rule. An alert on a Tier 1 asset requires human approval before any isolation or credential revocation, because isolating it is itself an outage. Tier 2 and Tier 3 assets may get automated low-blast-radius actions (step-up authentication, ending a single session) while an analyst reviews. Automated host isolation stays off for every tier until the detector has been validated on production data. The Evaluation page applies this rule to the simulated alerts.

Limitations of this layer

The graph, call volumes and tiers are illustrative. Removal impact treats every dependency as hard: a service is counted as impacted if it loses any dependency, with no allowance for caches, retries or failover replicas. The tier cut-offs are judgment calls and should be set with the service owners. A production version would build \(P\) from observed call logs, test the first-order Markov assumption against session traces, and check the tiers against past incidents.