Adaptive semantic guardrails : Dynamic magic square obfuscation as a positional cipher for NL2SQL environments
*Rahul Kumar SharmaCorresponding authorrahulsharma21@gmail.comSchool of Computer Science & Information Technology (SCSIT)Devi Ahilya VishwavidyalayaIndore, Madhya Pradesh, 452001, IndiaView full profile → , Vivek Kapoorvkapoor@ietdavv.edu.inDepartment of Information TechnologyInstitute of Engineering & TechnologyDevi Ahilya VishwavidyalayaIndore, Madhya Pradesh, 452017, IndiaView full profile →
* Corresponding author · click or hover a name for details
- Received:
- 01 Apr 2026
- Published Online:
- 31 Oct 2026
- Article type:
- Research Article
- Language:
- EN
- Article no.:
- JDMSC-3092
- Pages:
- 4787–4794
Abstract
Natural Language to SQL (NL2SQL) interfaces has made data far more accessible, but they have also opened up a new kind of weakness we call “Semantic Drift.” Because these systems are probabilistic, a Large Language Model (LLM) can produce SQL that is syntactically correctyet still breaks implicit privacy rules through hallucination or adversarial prompt injection. Conventional, deterministic security models are not built for this: they check identity, not semantic intent. To close that gap, we apply discrete combinatorial mathematics—specifically, dynamically generated Magic Squares—to build a positional symmetric cipher that functions as an adaptive Moving Target Defense (MTD). A Tri-State Decision Engine sits inside transparent JDBC middleware, balancing data integrity against active defense. When a query looks anomalous, the system responds with high-entropy obfuscation generated through the Siamese method, scrambling sensitive data on the fly and defeating frequency analysis in the process. In our evaluation, this approach caught 97.4% of adversarial injections while adding only 6.8ms of latency overhead, pointing toward a new cryptographic standard for zero-trust database connectivity in AI-driven systems.
Keywords
Subject Classifications
References
[1] R. K. Sharma and V. Kapoor, “A Generic Data Privacy Approach for Relational Databases and Data Warehouse,” International Journal of Intelligent Systems and Applications in Engineering (IJISAE), vol. 11, no. 3, pp. 1286-1289 (2023).
[2] R. K. Sharma and V. Kapoor, “Implementing Row and Column Level Security in Hive,” International Journal of Advanced Research in Computer Engineering & Technology (JARCET), vol. 6, no. 9. pp. 1329-1332 (2017).
[3] R. K. Sharma and V. Kapoor, “Generic Row Filtering and Column Masking for Fine-Grained Data Access Control through Secure JDBC Drivers,” Journal of Information and Optimization Sciences, vol. 47, no. 5-B, pp. 1955–1964 (2026), doi: 10.47974/JIOS-2287.
[4] J. Devlin, M. W. Chang, K. Lee, and K. Toutanova, “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding,” NAACL-HLT (2019).
[5] F. T. Liu, K. M. Ting and Z. -H. Zhou, “Isolation Forest,” Eighth IEEE International Conference on Data Mining, Pisa, Italy, pp. 413-422 (2008).
[6] S. Jajodia, A. K. Ghosh, V. Swarup, C. Wang, and X. S. Wang, Eds., Moving Target Defense: Creating Asymmetric Uncertainty for Cyber Threats, 1st ed., vol. 54, Advances in Information Security. New York, USA: Springer (2011), doi: 10.1007/978-1-4614-0977-9.
[7] K. Greshake, S. Abdelnabi, S. Mishra, C. Endres, T. Holz, and M. Fritz, “Not what you’ve signed up for: Compromising real-world LLM-integrated applications with indirect prompt injection,” in Proc. 16th ACM Workshop on Artificial Intelligence and Security (AISec ‘23), pp. 79–90 (2023), doi: 10.1145/3605764.3623985.
[8] NIST, “Security Techniques for the Generative AI Era,” NIST Special Publication 800-160, vol. 2 (2024).
[9] M. Pickard, “Magic Squares in Cryptography,” Journal of Recreational Mathematics (2010).
[10] A. K. Mishra, B. K. Singh, and S. Kumar, “A review on cryptographic matrix transformations in communication networks,” Journal of Information and Optimization Sciences, vol. 41, no. 4, pp. 911–924 (2020).
[11] R. Prasad, P. K. Verma, and S. Taru, “A novel framework for discrete combinatorial key distribution,” Journal of Interdisciplinary Mathematics, vol. 24, no. 5, pp. 1105–1118 (2021).
[12] S. Johri and H. K. Sharma, “Analytical modeling of secure dynamic data stream filtering layers,” Journal of Statistics and Management Systems, vol. 25, no. 3, pp. 641–653 (2022).




