1
Defending the Core: A Centrality-Based Protection Strategy for Supply Chain Security in npm Dependency Network
arXiv:2606.14036v1 [cs.CR] 12 Jun 2026
Wang Zixin, [email protected]
Abstract—The modern software supply chain, taking Node Package Manager (npm) dependency network for example, relies heavily on shared open-source dependencies. While this promotes rapid development, it introduces systemic vulnerabilities as well. Concerning this potential risk, we analyze the npm dependency network by modeling 53,481 packages and 78,520 dependency edges, and classify the network as a scale-free topology. Thus, we demonstrate its inherent vulnerability to targeted attacks on high-degree hubs. To mitigate this, we propose and evaluate a dual-pronged defense strategy consisting of Centrality-Based Node-Hardening and Dependency Weight Warning system. Moreover, by simulating the network under various attack scenarios, we prove that applying strict security protocols to just the top 1% of nodes, combined with pruning 30% of structurally trivial edges, prevents catastrophic network collapse and neutralizes cascading malware infections. The source code can be found at https://github.com/5tarWhee1/CentralityBased-Protection-Strategy-for-Supply-Chain-Security-in-npmDependency-Network. Index Terms—Supply Chain Security, npm Dependency Network, Scale-Free Network, Centrality-Based Defense, Node Hardening, Dependency Weight Warning
I. I NTRODUCTION
T
HE Node Package Manager (npm) ecosystem serves as the foundational infrastructure of modern JavaScript and Node.js development. With over one million publicly available packages and billions of weekly downloads, npm represents one of the largest software dependency networks ever constructed. However, it is structurally fragile under certain scenarios, resulting in a vulnerability that standard security practices fail to address. For example, the ”Sandworm” supply chain poisoning attack on the npm in May 2026 caused severe impact on developers. By quietly injecting obfuscated malware into seemingly harmless dependencies, the attackers exploited the highly interconnected nature of npm to spread malicious code downstream at a terribly exponential rate. The central problem is rooted in the network’s topology itself which creates an asymmetric vulnerability. Through empirical simulation, we demonstrate that the npm dependency graph exhibits the structural properties of a scale-free network: a topology where a minority of highly-connected hub packages bear the structural load for the entire ecosystem. Such network property arises from the preferential attachment mechanism [1], making it statistically robust against random failures yet catastrophically fragile when those specific hubs are targeted [2]. As shown in Fig. 1, a single hub package in 2018 can expose over 166,000 downstream projects to any vulnerability it carries. Standard uniform security measures are
Fig. 1. Growth of package reach in the npm ecosystem, 2010–2018. By 2018, the top-5 packages each reach between 134,774 and 166,086 downstream dependents transitively, making them high-value targets for supply-chain attacks. Reproduced from [8], Fig. 4.
therefore both economically infeasible and structurally misdirected. Therefore we are committed to proposing a protection strategy better suited to scale-free networks. Our work can be summarized as four main contributions: We rigorously verify the scale-free property of the npm dependency graph through power-law fitting, comparison with an Erdős-Rényi random graph, and degree-inequality metrics. • Second, we demonstrate the vulnerability arising from this topology through a network degradation simulation. • Third, we propose and simulate a dual-pronged defense strategy consisting a Centrality-Based Node-Hardening
•
2
•
and Dependency Weight Warning system. Fourth, both proposals are verified under three distinct attack scenarios, and we prove that in a network of 53,481 packages, protecting a carefully selected 534 nodes is sufficient to preserve the integrity of the entire ecosystem. II. BACKGROUND AND R ELATED W ORKS
A. Node Package Manager npm (Node Package Manager) is a platform for publishing and hosting JavaScript packages, and is by far the largest ecosystem of its kind. npm provides a command-line interface (CLI) for publishing and installing packages, as well as an online repository for hosting all packages and their metadata. All npm packages contain a file named “package.json” which declares its direct dependencies, and npm resolves the full transitive dependency tree at install time. This design enables rapid code reuse but creates a web of mutual dependencies that constitutes a complex directed graph whose structural properties we analyze in this paper. B. Software Supply Chain Vulnerability The systemic risks embedded in open-source dependency ecosystems have received growing attention from both academia and industry. Zimmermann et al. [8] conducted the first large-scale empirical study of security vulnerability propagation in npm, finding that a single vulnerable package can transitively expose over 100,000 dependent projects. Their analysis reveals an average vulnerable dependency depth of 5.4 hops, meaning developers are often unaware of the true extent of their attack surface. Zahan et al. [9] further characterize “weak links” in the npm supply chain, identifying that package maintainer account security is the dominant risk factor for large-scale compromise events. On the practitioner side, the Open Source Security Foundation(OpenSSF) Security Scorecard project [10] proposes a 10factor scoring rubric to evaluate the security posture of Open Source projects, including branch protection, code review, and automatic dependency update. While valuable, these approaches treat all packages uniformly; our work demonstrates that uniform treatment is both economically infeasible and structurally unjustified. C. Scale-Free Network The concept of scale-free networks originates from the pioneering work of Barabási and Albert [1], who demonstrated that networks generated by preferential attachment mechanism, where new nodes connect disproportionately to existing high-degree nodes, naturally exhibit a power-law degree distribution P (k) ∼ k −γ with γ ∈ [2, 3]. This “rich-get-richer” dynamic is precisely the core mechanism governing npm: popular packages such as lodash accumulate a large number of dependencies just because developers tend to choose libraries that are well-documented and widely adopted. Newman [4] provides a comprehensive treatment of the structural properties arising from this mechanism, including the extreme degree
Fig. 2. Summary of the response of exponential network and scale-free network to failures or attacks.Reproduced from [2], Fig. 4.
heterogeneity (high κ = ⟨k 2 ⟩/⟨k⟩) that is central to our analysis. Power-law detection in empirical data requires statistical rigour beyond visual log-log linearity. Clauset et al. [3] establish maximum likelihood estimation (MLE) combined with Kolmogorov-Smirnov testing as the standard, and our feature extraction pipeline directly adopts their methodology. D. Network Robustness and Attack Tolerance With regard to network robustness, Albert et al. [2] establish the foundational theoretical conclusion as Fig.2 shows: scalefree networks are robust against random failures (high error tolerance) but fragile under targeted removal of high-degree key nodes (low attack tolerance). As their comparison demonstrates, random graph networks degrade smoothly under both failure modes, whereas scale-free networks exhibit near-zero degradation under random removal but collapse rapidly under targeted attack. This “robust-yet-fragile” duality is the theoretical bedrock of our security proposal. The same structure is formalised through percolation theory, where the critical threshold fc = 1 − 1/(κ − 1) quantifies the fraction of random removals required to fragment the network; high κ implies high fc , meaning scale-free networks tolerate neartotal random removal but have a much lower targeted attack threshold [4]. Pastor-Satorras and Vespignani [5] extend this analysis to epidemic spreading, proving that scale-free networks have a vanishing epidemic threshold: an infection starting at a hub diffuses through the network with probability approaching 1. This directly motivates our cascade malware simulation. E. Dependency Network Structure and Analysis Kikas et al. [6] conduct the most directly relevant prior structural analysis of software package dependency networks, including npm, RubyGems, and CRAN. Their work documents power-law degree distributions, high levels of clustering, and the presence of structural “super-hubs,” and warns that the rapid growth of these networks exacerbates their vulnerability. Wittern et al. [7] analyse the longitudinal dynamics of npm, noting that preferential attachment accelerates over time as the registry grows.
3
The key distinction between our research and these structural analyses lies in its core contribution: we move beyond diagnosis to operational solution design, implementing and evaluating concrete security mechanisms grounded in the network’s structural properties. III. M ETHODOLOGY A. Data Construction Our dataset is a directed dependency graph extracted from the npm public registry via Google BigQuery. Each node represents a unique package; a directed edge from source u to target v indicates that package u declares v as a dependency. After deduplication and removal of edges with missing endpoints, the graph contains N = 53,481 nodes and M = 78,520 edges, with density ρ = M/N (N − 1) = 2.75 × 10−5 . Centrality metrics. For each node v, we calculate the indegree centrality k in (v) and PageRank centrality P R(v) as defined in Eqs. 1 and 2 respectively: k in (v) = |{u ∈ V : (u, v) ∈ E}| X P R(u) 1−d +d P R(v) = N L(u)
(1) (2)
u∈B(v)
where d = 0.85 is the damping factor borrowed from Google’s original web-ranking algorithm, which represents the probability a ”random walker” tends to follow dependency links rather than jump to a random package. B(v) is the set of nodes whose edges point to v, and L(u) is the out-degree of u. The composite criticality score is defined as below and any package in the top 1% by this score is designated a Critical Node: d s(v) = 0.6 · k̂ in (v) + 0.4 · P R(v) (3) where ˆ· denotes normalization to [0, 100]. It ranks every package’s criticality using a composite score with in-degree and PageRank rather than in-degree alone, which makes the Critical Node selection more robust. Network health. To evaluate the network health, we calculate the size of Largest Weakly Connected Component (LCC) which represents the size of the largest group of packages that are still mutually reachable after some nodes have been removed: H(G) = max |C| (4) C∈W(G)
where W(G) is the set of weakly connected components (WCCs) of directed graph G. B. Network Characterization We verify the scale-free property through four complementary tests, which are implemented in network_characterization.py. Power-law fitting. To confirm that the network is truly scale-free, we apply the statistical framework established by Clauset et al. [3]. Using Maximum Likelihood Estimation (MLE), we fit a power-law distribution to the tail of the indegree distribution (all nodes with k ≥ xmin )”. To determine exactly where this operation begins (xmin ), we select the starting point that minimize the Kolmogorov-Smirnov distance,
ensuring the closest possible match between our real data and the theoretical formula. Finally, we use a likelihood ratio test to rule out alternative models, such as lognormal and exponential distributions, definitively proving the presence of scale-free hubs. Erdős-Rényi comparison. We construct a null-model ER graph G(N, p) with identical N and M (hence p = M/N (N − 1)) and compare degree variance, clustering coefficient, and component structure. Degree inequality metrics. We compute the Gini coefficient of the in-degree distribution that represents the degree of inequality in the in-degree distribution: PN P in 2 i=1 i · k(i) − (N + 1) k in P (5) G= N k in and the heterogeneity coefficient showing how much the highdegree hubs dominate the second moment relative to the mean: κ=
⟨k 2 ⟩ ⟨k⟩
(6)
which governs the percolation threshold fc = 1 − 1/(κ − 1) under random removal in the mean-field approximation. Preferential attachment evidence. We bin nodes by indegree and measure the edge-share captured by each bin, testing whether the fraction of edges pointing to high-degree nodes is significantly greater than random expectation. C. Proposal A: Centrality-Based Node-Hardening Any package whose composite score s(v) (Eq. 3) falls in the top 1% threshold of the distribution is classified as Critical Node, yielding 534 Critical Nodes from 53,481. Kcore decomposition [4] and approximate betweenness centrality (computed with k = 100 sampled shortest paths) serve as supplement for in-degree to identify structural bottlenecks, namely nodes with moderate in-degree but high betweenness. After sorting, Critical Nodes should be subject to a tiered set of mandatory security obligations enforced through a pre-publish gate: • CRITICAL tier (top 1%): Mandatory 2FA for all maintainers; manual code audit before publication; locked semantic versioning; daily hash-integrity verification by the registry; OpenSSF institutional funding eligibility. • HIGH tier (top 1%–5%): Mandatory 2FA; locked versioning; automated dependency scanning. To enforce this policy, we propose an automated compliance gate that triggers whenever there are attempts to publish an update to a Critical Node. The system verifies that all mandatory security requirements are met before the package can go live. If any check fails, publication is strictly blocked, and the maintainer is automatically issued a detailed remediation report explaining exactly how to resolve the compliance issues. The logic for this enforcement mechanism is formalized in Algorithm 1. In the attack simulation, hardened nodes are able to resist removal: when the attacker attempts to compromise a Critical Node, there is a very high probability that they will be blocked by the protective measures introduced by our pipeline;
4
Algorithm 1 Pre-Publish Gate for Critical Nodes Require: Package name p, version v 1: tier ← classify(p) 2: if tier = STANDARD then 3: return APPROVED 4: end if 5: R ← requirements(tier) 6: F ← {r ∈ R : ¬compliant(p, r)} 7: if F ̸= ∅ then 8: return BLOCKED(F ) 9: else 10: return APPROVED 11: end if
and the attacker will fall back to the next-highest-degree unprotected target. Formally, for an ordered attack sequence σ = (v1 , v2 , . . .): /H delete vi if vi ∈ remove(vi ) = delete vi if vi ∈ H (prob pbreach ) skip if vi ∈ H (prob 1 − pbreach ) (7) where H is the hardened set. The simulation result will be shown in Section IV. D. Proposal B: Dependency Weight Warning (DWW) System An edge (u, v) is defined low-value / high-risk if: v ∈ Htop1% ∧ k out (u) ≤ θ
(8)
where Htop1% is the set of Critical Nodes (top-1% in-degree) and θ = 3 is the low-dependency threshold. This identifies cases where a small package imports a critical hub despite likely being able to implement the required functionality natively. Each flagged edge is assigned a risk score: r(u, v) = 0.50 · p100 (v) θ − k out (u) + 1 + 0.35 · max 0, · 100 θ + 0.15 · 1[k out (u) = 1]
(9)
where p100 (v) is the percentile rank of v’s in-degree. Scores are classified as CRITICAL (r ≥ 80), HIGH (r ≥ 55), or MEDIUM (r ≥ 30). When conducting npm installation the DWW system queries the edge’s risk score. If CRITICAL or HIGH, it displays the package, risk score, hub status, and a concrete recommendation. Crucially, the DWW warns but never hard-blocks: it provides the information needed for an informed architectural decision without interrupting developer workflow. Edge pruning removes all flagged edges from the graph, yielding a residual graph G′ = (V, E \ Ef lagged ). This reduces κ by redistributing in-degree load away from hubs and decreasing the hub edge concentration ratio: η=
|{(u, v) ∈ E : v ∈ Htop1% }| |E|
(10)
Fig. 3. npm network characterization. Upper: Log-log in-degree distribution with MLE power-law fit (γ = 2.06, xmin = 7, KS= 0.023). Lower-left: The top 50 packages’ distribution shows a Zipf-like rank-degree curve. Lowerright: Edge-share by degree bin confirming preferential attachment (the top 0.02% of packages capture 9.4% of all edges).
IV. E XPERIMENTS A. Experimental Setup All experiments are implemented in Python 3.8.20 using NetworkX 3.6 and run on a standard development machine (Intel Core i5, 16 GB RAM). Graph construction and centrality computation for the full 53,481-node graph complete in under 90 seconds, confirming operational feasibility. All random processes use seed 42 for reproducibility. Four conditions are compared throughout: 1) No Protection: baseline, no hardening or pruning. 2) Proposal A: hardened hub set H, base graph. 3) Proposal B: pruned graph G′ , no hardening. 4) Combined A+B: hardened hub set on pruned graph G′ . B. Scale-Free Property Verification We’ve calculated the properties of the npm network and Fig. 3 and Table I exhibit the results of our comprehensive network characterization analysis. The empirical data strongly satisfies all four criteria outlined in our methodology, confirming the scale-free topology of the npm ecosystem. Power-law fitting. The Maximum Likelihood Estimation (MLE) applied to the heavy tail of the in-degree distribution yields a power-law exponent of γ = 2.0622 (σ = 0.028). This falls perfectly within the theoretical scale-free regime of γ ∈ [2, 3]. The fit is statistically rigorous, achieving a Kolmogorov-Smirnov (KS) statistic of 0.023 at xmin = 7. Furthermore, the likelihood ratio test decisively rejects the alternative exponential distribution (R = 797.6, p < 10−4 ); the comparison with the log-normal distribution remains ambiguous (R = 0.016, p = 0.459), which is highly consistent with the literature on empirical power laws [3]. Erdős-Rényi comparison. The scale-free nature becomes starkly apparent when contrasted with the Erdős-Rényi (ER) null model as shown in Table I. While both networks share the exact same number of nodes and edges (and thus the same mean in-degree of 1.47), their structures are fundamentally
5
TABLE I N ETWORK C HARACTERIZATION S UMMARY Property Nodes N Edges M Max in-degree Mean in-degree Std. in-degree Gini coefficient Heterogeneity κ Power-law exponent γ Transitivity LCC fraction Top-1% edge share
npm
ER Null Model
53,481 78,520 1,218 1.47 14.66 0.90 147.8 2.06 0.00106 79.5% 54.7%
53,481 78,520 ≈22 1.47 1.21 ≈0.32 ≈2.2 — 0.0000275 ≈99% ≈1%
divergent. The ER model exhibits a normal distribution with a maximum in-degree of approximately 22 and a standard deviation of 1.21. In contrast, the empirical npm network possesses a maximum in-degree of 1,218 and a standard deviation 12 times higher (14.66), proving the existence of statistically unnatural super-hubs. Degree inequality and percolation. This structural imbalance is quantified by a Gini coefficient of 0.90, indicating massive, systemic inequality where a tiny elite fraction of nodes hoards the vast majority of edges. More critically, the heterogeneity coefficient reaches an extreme κ = 147.8 (compared to κ ≈ 2.2 for the ER model). In percolation theory, this extremely high κ yields an implied critical percolation threshold of fc = 1−1/(κ−1) ≈ 0.9932. Mathematically, this dictates that one would need to randomly remove 99.3% of the packages in the registry to fragment the network, explaining its extraordinary resilience against random failures.
Fig. 4. Network degradation under targeted hub attack vs. random failure (200 packages removed, batch size 10).
Fig. 5. SI-model malware cascade starting from 5 compromised hub packages.
Finally, the edge-share metrics confirm the underlying ”richget-richer” generative mechanism. As shown in the lower-right of Fig. 3, the top 0.02% of packages capture 9.4% of all edges, and the top 1% of nodes (534 packages) control an overwhelming 54.7% of all dependency links. In summary, the combination of a verified power-law exponent (γ ≈ 2.06), extreme heterogeneity (κ ≈ 147.8), and massive hub dominance confirms the scale-free property of the npm dependency graph. This topological reality dictates that the network is highly robust to random errors but critically fragile to targeted attacks on its hubs, thereby providing the scientific justification for our Centrality-Based Node-Hardening strategy. Since scale-free network is born with the “robust-yetfragile” duality property as proposed by Albert et al. [2], we’ve conducted a comparative experiment shown in Fig. 4. Random removal of 200 packages reduces the LCC by less than 1.5%; the same number of targeted hub removals reduces it by 37.8%. The curve of targeted attack shows significant degradation, reflecting the cascading effect of removing structural hubs that bridge sub-communities. This result motivates our security proposal: uniform protection is kind of wasteful because the random threat is nearly negligible; only targeted protection of hubs is necessary.
Fig. 6. Beta Sensitivity Analysis illustrating the protection effectiveness across varying malware transmission probabilities (β ∈ [0.1, 1.0]).
C. Malware Cascade Simulation As the attack often reflects cascading effect, we implement a discrete Susceptible-Infected (SI) cascade on the directed dependency graph, motivated by the epidemicspreading framework of Pastor-Satorras and Vespignani [5], to model real-world supply-chain malware propagation as in the ua-parser-js and event-stream incidents. At each step, every infected node v propagates the infection to all predecessors u ∈ B(v) (packages that depend on v), unless u is hardened or the edge (u, v) has been pruned. Then select 5 hub
6
packages from the top-50 as initial infection seeds. However, the transmission rate (β) is heavily penalized when malware attempts to propagate through a hardened node, given the efficacy of strict version locking and automated audit pipelines. As shown in Fig. 5, under a moderate transmission rate (β = 0.40), the unprotected baseline suffers a catastrophic cascade resulting in 1,977 infected packages. Proposal A (Node Hardening) successfully intercepts the downstream propagation, limiting the damage to 406 packages. Most notably, the Combined A+B strategy, which supplements hardened hubs with pruned edges, chokes the cascade down to just 131 packages, achieving a remarkable 93.4% reduction in systemic compromise. These results corroborate the theoretical prediction of Pastor-Satorras and Vespignani [5] that hub protection is the decisive intervention for epidemic containment in scalefree networks. To ensure the robustness of this defense, we further conduct a Beta Sensitivity Sweep as Fig. 6 shows. The Combined Strategy consistently maintains over an 85% infection reduction rate across all tested contagiousness levels, proving its efficacy against both slow-moving vulnerabilities and highly aggressive exploits.
Fig. 7. Network response to a targeted hub attack.
D. Disturbance Response Under Multiple Attack Scenarios We evaluate network resilience under multi-wave disturbances (5 waves × 20 packages per wave) across three scenarios: Targeted—attacker always removes highest in-degree packages; Random—packages are removed uniformly at random; Mixed—waves alternate between targeted and random removal. A realistic breach probability of pbreach = 0.15 is applied to hardened nodes in the targeted and mixed scenarios, reflecting that real-world maintainers achieve imperfect compliance with security requirements. Network health is measured after each wave and during an 8-step post-attack observation phase. It should be noted that in the figures of this subsection, the lower starting LCC for Proposal B and Combined A+B reflects the pre-emptive removal of trivial edges by Proposal B, not attack degradation. Targeted Hub Disturbance. Conversely, under a targeted hub attack as Fig. 7, the baseline network fragments rapidly. When the most central packages are systematically removed, the unprotected baseline LCC drops to 71.7%, isolating tens of thousands of packages. Proposal A acts as an effective structural shield; by hardening the top 1% of hubs, the attacker is blocked, and the network holds strong at 94.7% health. Random Disturbance. Under a purely random attack scenario as Fig. 8, the scale-free nature of the network renders both the baseline and the protected models virtually impressive, maintaining ∼99% structural health. Because random attacks overwhelmingly strike peripheral leaf nodes (which have an out-degree of zero), the network’s core remains untouched. This indicates that uniform, ecosystem-wide security protection is economically wasteful. What should be clarified is that the visible gap in absolute LCC size between
Fig. 8. Network response to a random multi-wave disturbance.
Proposal A and Combined A+B is an artifact of Proposal B’s pre-emptive edge pruning, rather than a result of attack degradation. Proposal B’s edge pruning disconnects singledependency leaf packages before the attack begins, lowering the starting LCC but eliminating structural fragility at those edges. Adaptive Mixed Attacks. To make the simulation more realistic and adaptive, we design a ”Mixed” attack scenario that alternates between targeted hub removal (Waves 1, 3, 5) and uniformly random removal (Waves 2, 4), which can be seen in Fig. 9. The results perfectly illustrate the extreme topological inequality of the npm ecosystem. During the hub-targeted waves, the baseline network suffers catastrophic
7
Fig. 10. Network response to escalating real-world threat vectors. The effectiveness of Centrality-Based Hardening scales inversely with attacker sophistication (pbreach ).
Fig. 9. Network response to a mixed attack. Waves 1, 3, and 5 target core hubs and waves 2 and 4 apply random removal, resulting in near-zero collateral isolation. TABLE II D ISTURBANCE R ESPONSE R ESULTS (5 WAVES × 20 PACKAGES ) Scenario
Strategy
Health
Wave 1 Loss
Targeted
No Protection Proposal A Proposal B Combined
71.7% 94.7% 87.9% 98.7%
≈5,400 ≈1,300 ≈1,100 ≈200
Random
No Protection Proposal A
99.3% 99.5%
≈20 ≈20
Mixed
No Protection Proposal A Proposal B Combined
77.3% 95.5% 91.3% 98.8%
≈5,400 ≈1,400 ≈1,100 ≈200
Fig. 11. Disturbance response isolated for the Credential Stuffing threat vector (pbreach = 0.03).
With pbreach = 0.15, no individual wave is fully absorbed, so the column is omitted.
collateral isolation. However, during Waves 2 and 4, collateral damage drops to near-zero across all strategies. This proves that supply-chain fragility is almost entirely localized within the top 1% of central packages; removing peripheral nodes yields virtually no cascading structural failure. E. Threat Vector Analysis To model these defenses realistically, we evaluate Proposal A against specific Threat Vectors with escalating breach probabilities (pbreach ), as shown in Fig. 10. Against automated threats such as ”Credential Stuffing” (pbreach = 0.03), the mandatory 2FA protocols of Proposal A effectively create an impenetrable wall, maintaining near 100% network health (shown in Fig. 11). However, against a sophisticated ”Zero-Day Exploit”(pbreach = 0.28) or ”Insider Threat” (pbreach = 0.42), protection predictably degrades: Proposal A retains 90.6% health against the former and 85% against the latter, which
Fig. 12. Disturbance response isolated for the Zero-Day Exploit threat vector (pbreach = 0.28).
can be seen in Fig.12. This demonstrates the realistic limits of centrality-based defense: while structural policies can neutralize automated supply-chain poisoning, mitigating
8
TABLE III Q UANTITATIVE E VALUATION M ETRICS M1–M11 ID
Metric
Before
After
Change
M1 M2 M3 M4 M5
Robustness index R Percolation threshold fc Hub coverage F1 Absorption rate† LCC drop / wave
0.141 0.4% — 0% 5,400
0.607 100% 0.811 — ∼1,300
+0.466 +99.6pp — — −76%
M6 M7 M8 M9 M10
Gini coefficient κ Natural connectivity Hub edge conc. η Edge risk reduction
0.901 147.8 0.131 54.9% 24,149
0.859 37.4 0.089 34.8% 0 remain
−0.042 −74.7% −0.042 −36.6% 100%
M11 M11 M11
Rob. gap (A) Rob. gap (B) Rob. gap (A+B)
R A − R0 RB − R0 RAB − R0
+0.466 −0.011∗ +0.129
†
Under ideal hardening (pbreach = 0): 100%; under realistic pbreach = 0.15: ≈ 0% (some nodes breached each wave). ∗ Negative due to leaf-node disconnection; see §V.
authorized, malicious insiders requires deeper semantic code analysis beyond the scope of pure network topology. F. Evaluation Metrics To provide a rigorous multi-dimensional evaluation beyond scenario simulations, we define twelve metrics across two categories. Proposal A metrics (M1–M5). The robustness index [11]: 1 X H(Gq ) R= (11) N q N measures the normalised area under the LCC curve as nodes are removed sequentially. The percolation threshold fc is the fraction of nodes removed when H(G)/N first drops below 0.5. Hub coverage quality is measured by the F1 score of the in-degree-based Critical Node selection against a PageRankbased ground truth. Attack absorption rate is the fraction of attack waves in which zero packages are isolated. Mean LCC drop per wave is the average packages newly isolated per wave. Proposal B metrics (M6–M10). Beyond the Gini and κ metrics already introduced (Eqs. 5, 6), we measure natural connectivity [12]: ! N 1 X λi λ̄ = ln e (12) N i=1 where λi are the eigenvalues of the adjacency matrix of the top-k hub subgraph (computed on a 800-node sample for tractability). The hub edge concentration ratio η (Eq. 10) and edge risk reduction rate complete the structural metrics. Table III presents all results. Fig. 13 visualises the five most informative metrics. Ultimately, the quantitative success of our dual-pronged approach exhibits the effectiveness of our combined strategy. Taken together, the metrics confirm that Proposal A raises R by +0.466 and eliminates the percolation risk (fc : 0.4% → 100%), while Proposal B reduces structural load concentration
by 36.6% and κ by 74.7%, providing complementary longterm resilience. By combining Centrality-Based Node Hardening with Dependency Weight Warning (Edge Pruning), the network achieves a paradigm where structural robustness is preserved while malware contagion pathways are systematically neutralized. V. C ONCLUSION AND L IMITATION We study the npm ecosystem and demonstrate that the npm dependency graph is a scale-free network, whose topology makes it catastrophically fragile to targeted hub attacks while remaining robust to random failures. To handle this vulnerability, we propose and evaluate the Targeted Node-Hardening Protocol (TNHP), a dual-mechanism defence grounded directly in the network’s structural properties. This mechanism includes the Centrality-Based Node Hardening and Dependency Weight Warning system. Through rigorous simulation of multi-wave attack scenarios and a comprehensive set of quantitative metrics, we show that TNHP can significantly reduce malware cascade size while maintaining near-perfect network health under targeted attacks. Our work provides a scalable, data-driven strategy for securing software supply chains by strategically strengthening the most critical nodes. However, there are limitations to our approach. First, while our composite metric successfully incorporates both in-degree and PageRank, it may still overlook specific topological bridges, namely those nodes with moderate degrees but extremely high out-degree that connect disparate ecosystems. Second, while our simulations model various attack scenarios, realworld attacks may involve more complex strategies that adapt to defenses, such as multi-vector attacks or insider threats. Finally, the implementation of mandatory security measures for critical nodes may face practical challenges in terms of developer compliance and ecosystem governance, which warrants further investigation into incentive structures and community engagement strategies. R EFERENCES [1] A.-L. Barabási and R. Albert,“Emergence of scaling in random networks,”Science, vol. 286, no. 5439, pp. 509–512, Oct. 1999. https://doi.org/10.1126/science.286.5439.509 [2] R. Albert, H. Jeong, and A.-L. Barabási, “Error and attack tolerance of complex networks,” Nature, vol. 406, no. 6794, pp. 378–382, Jul. 2000. https://doi.org/10.1038/35019019 [3] A. Clauset, C. R. Shalizi, and M. E. J. Newman, “Power-law distributions in empirical data,” SIAM Rev., vol. 51, no. 4, pp. 661–703, Nov. 2009. https://doi.org/10.1137/070710111 [4] M. E. J. Newman, Networks: An Introduction. Oxford, U.K.: Oxford Univ. Press, 2010. [5] R. Pastor-Satorras and A. Vespignani, “Epidemic spreading in scale-free networks,” Phys. Rev. Lett., vol. 86, no. 14, pp. 3200–3203, Apr. 2001. https://doi.org/10.1103/PhysRevLett.86.3200 [6] R. Kikas, M. Dumas, and D. Pfahl, “Structure and evolution of package dependency networks,” in Proc. 14th IEEE/ACM Int. Conf. Mining Softw. Repos. (MSR), Buenos Aires, Argentina, 2017, pp. 102–112. https://doi.org/10.1109/MSR.2017.55 [7] E. Wittern, P. Suter, and S. Rajagopalan, “A look at the dynamics of the JavaScript package ecosystem,” in Proc. 13th IEEE/ACM Int. Conf. Mining Softw. Repos. (MSR), Austin, TX, USA, 2016, pp. 351–361. https://doi.org/10.1145/2901739.2901743
9
Fig. 13. Quantitative evaluation dashboard (M1–M11). Upper: Robustness curves (M1+M2) for all four conditions over 5,000 targeted removals. Middle-left: Proposal A metrics before/after hardening. Middle-right: Proposal B metrics before/after pruning. Lower-left: Robustness gap M11 for all three protected strategies. Lower-right: Heterogeneity κ and theoretical percolation threshold (M7)—edge pruning moves κ from 147.8 to 37.4.
[8] T. Zimmermann, P. Sharma, S. Rajagopalan, A. Metzger, L. Song, and A. Vitek, “Small world with high risks: A study of security vulnerabilities in dependencies,” in Proc. 28th USENIX Security Symp.,
Santa Clara, CA, USA, 2019, pp. 995–1010. https://www.usenix.org/conference/usenixsecurity19/presentation/ zimmermann
10
Fig. 14. Overall evaluation metrics comparing the structural Robustness Index (R) and Cascade Reduction efficiencies across all proposed strategies.
[9] J. Zahan, T. Clark, P. Saha, B. William, and L. Williams, “What are weak links in the npm supply chain?” in Proc. 44th IEEE/ACM Int. Conf. Softw. Eng. (ICSE-SEIP), Pittsburgh, PA, USA, 2022, pp. 331– 340. https://doi.org/10.1145/3510457.3513044 [10] Open Source Security Foundation (OpenSSF), “Security Scorecard: Automated security checks for open source projects,” 2023. https://securityscorecards.dev [11] C. M. Schneider, A. A. Moreira, J. S. Andrade, S. Havlin, and H. J. Herrmann, “Mitigation of malicious attacks on networks,” Proc. Nat. Acad. Sci., vol. 108, no. 10, pp. 3838–3841, 2011. https://doi.org/10.1073/pnas.1009440108 [12] W. Jun and G. Barahona, “Natural connectivity of complex networks,” Chin. Phys. Lett., vol. 27, no. 7, p. 078902, 2010. https://doi.org/10.1088/0256-307X/27/7/078902