Metaverse Security: LLM-Based Malicious Code Detection Through Token Optimization
Metaverse platforms increasingly offer immersive virtual environments while simultaneously introducing significant vulnerabilities through malicious code, particularly when concealed within software supply chains. To address these security challenges, this study utilizes Large Language Models (LLMs) for the detection of harmful JavaScript code. Specifically, it underscores the pivotal role of optimising input token length in order to enhance both detection accuracy and overall computational efficiency. To examine this optimisation process, we conduct an empirical comparison of several advanced LLMs—namely CodeLLaMA, LLaMA-2/3, Qwen2.5, and EXAONE-3.5—across token ranges from 500 up to 128K. Our findings reveal that the optimal input size varies considerably among these models, indicating that arbitrarily enlarging token counts does not inherently improve performance. Notably, Qwen2.5 achieves an F1 score of 0.9276 at an input size of 5120 tokens, thereby surpassing diverse conventional approaches as well as large-context baselines. This outcome highlights the viability of tailored input lengths as a practical and efficient security measure for metaverse ecosystems. By adhering to an optimal token length strategy, our study not only diminishes computational overhead but also accelerates inference times, a crucial consideration in safeguarding modern metaverse infrastructures. These results confirm that a carefully calibrated approach to token length can strike a balance between precision and resource management, offering an effective mechanism to thwart malicious JavaScript activity. Consequently, this line of inquiry opens the way for LLM-driven security frameworks that combine thorough threat detection with tangible gains in computational performance.
Authors
- Seongmin Park (ORCID: https://orcid.org/0000-0002-2519-0707)
- Eunmi Choi (ORCID: https://orcid.org/0000-0002-9743-2437)
- Tuan Anh Nguyen (ORCID: https://orcid.org/0000-0001-9328-7693)
- Dugki Min
Institutions
- Kookmin University (KR)
- Konkuk University (KR)
- Ho Chi Minh City University of Industry and Trade (VN)
Publication Details
- Published
- 2025-08-27
- DOI
- https://doi.org/10.1109/metacom65502.2025.00057
- Primary Topic
- Advanced Malware Detection Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00