信息网络安全 ›› 2025, Vol. 25 ›› Issue (8): 1313-1325.doi: 10.3969/j.issn.1671-1122.2025.08.011
收稿日期:2024-10-25
出版日期:2025-08-10
发布日期:2025-09-09
通讯作者:
阮树骅
E-mail:ruanshuhua@scu.edu.cn
作者简介:张燕怡(2000—),女,四川,硕士研究生,主要研究方向为云计算安全|阮树骅(1966—),女,浙江,副教授,硕士,主要研究方向为云计算与大数据安全、区块链安全|郑涛(1994—)男,四川,博士研究生,主要研究方向为移动安全和软件安全分析
基金资助:
ZHANG Yanyi1,2,3, RUAN Shuhua1,2,3(
), ZHENG Tao1,2,3
Received:2024-10-25
Online:2025-08-10
Published:2025-09-09
摘要:
在REST API的设计和开发过程中,遵循 REST原则以及最佳实践等规范,对确保REST API服务的一致性、可用性和安全性是至关重要的。针对 REST API设计检测领域中存在的安全维度及语义层面检测机制不完善问题,文章提出一个REST API设计安全性检测框架RADSD,旨在从不同结构层次对API设计的安全性进行检测。首先,通过收集整理 REST API相关指导规范并结合实证研究,构建了一个多层次的 REST API 安全设计规范库;然后,针对规范库中各项规范要求设计对应的检测算法,并将大语言模型引入REST API设计检测,实现针对API设计语法和语义的多种检测方法。实验结果证明,RADSD框架能够对业界真实REST API进行多层次检测,识别API存在的设计安全性问题,并生成详细的检测报告,平均准确率达97.1%。
中图分类号:
张燕怡, 阮树骅, 郑涛. REST API设计安全性检测研究[J]. 信息网络安全, 2025, 25(8): 1313-1325.
ZHANG Yanyi, RUAN Shuhua, ZHENG Tao. Research on REST API Design Security Testing[J]. Netinfo Security, 2025, 25(8): 1313-1325.
表1
REST API安全设计规范库
| 编号 | 规范描述 | 类别 |
|---|---|---|
| U-1 | URI中必须使用分隔符/表示层次关系[ | URI 安全 |
| U-2 | URI中不能包含尾随的斜杠(/)[ | |
| U-3 | URI中应该使用“-”而不是“_”作为连接符[ | |
| U-4 | URI路径应该使用小写字母[ | |
| U-5 | URI中不能包含文件扩展名[ | |
| U-6 | URI中不能出现CRUD方法名[ | |
| P-1 | 查询参数中避免出现版本号[ | 参数 安全 |
| P-2 | 查询参数中避免出现CRUD方法名[ | |
| P-3 | 同一参数的类型定义不能发生冲突[ | |
| P-4 | 敏感参数不能在URL上传播[ | |
| P-5 | 参数默认值应该安全配置[ | |
| H-1 | 对资源的操作必须遵循HTTP协议定义的标准方法[ | HTTP交互 安全 |
| H-2 | 自定义HTTP头不能用来改变HTTP方法的行为[ | |
| H-3 | GET和POST方法不能用于隧道其他请求方法[ | |
| H-4 | 响应必须遵循HTTP协议定义的标准响应码及 状态描述[ | |
| H-5 | 401 (“Unauthorized”)响应在需要验证身份认证时必须 使用[ | |
| R-1 | 请求/响应消息头中必须包含“Content-Type”[ | HTTP消息 安全 |
| R-2 | 请求/响应消息表示应该支持JSON格式[ | |
| S-1 | API应该正确配置身份认证/授权机制[ | 安全 方案 |
| S-2 | API应该正确配置安全传输协议[ | |
| S-3 | API应该正确配置HTTP安全头[ | |
| L-1 | 自链接应该使用一致且正确的表单来表示 | 自链接 安全 |
| I-1 | 同一服务的API应该使用一致的子域名[ | 服务 管理 安全 |
| I-2 | API信息中应该具有版本声明[ |
表4
RADSD正确性验证结果
| 规范编号 | 准确率 | 召回率 | 规范 编号 | 准确率 | 召回率 | 规范 编号 | 准确率 | 召回率 | 规范 编号 | 准确率 | 召回率 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| U-1 | 100% | 100% | P-1 | 100% | 100% | H-2 | 100% | 100% | S-1 | 100% | 100% |
| U-2 | 100% | 100% | P-2 | 95% | 96% | H-3 | 86% | 84% | S-2 | 93% | 92% |
| U-3 | 100% | 100% | P-3 | 94% | 82% | H-4 | 92% | 93% | S-3 | 100% | 100% |
| U-4 | 100% | 100% | P-4 | 97% | 98% | H-5 | 95% | 98% | L-1 | 96% | 97% |
| U-5 | 97% | 98% | P-5 | 96% | 96% | R-1 | 97% | 88% | I-1 | 100% | 100% |
| U-6 | 94% | 97% | H-1 | 100% | 100% | R-2 | 98% | 92% | I-2 | 100% | 100% |
| [1] | FIELDING R T. Architectural Styles and the Design of Network-Based Software Architectures[M]. Irvine: University of California, 2000. |
| [2] | HIGGINBOTHAM J. Principles of Web API Design: Delivering Value with APIs and Microservices[M]. Boston: Addison-Wesley Professional, 2021. |
| [3] | ZHOU Xinyu, CHEN Wei, WU Guoquan, et al. REST API Design Analysis and Empirical Study[J]. Journal of Software, 2022, 33(9): 3271-3296. |
| 周芯宇, 陈伟, 吴国全, 等. REST API 设计分析及实证研究[J]. 软件学报, 2022, 33(9): 3271-3296. | |
| [4] | RAUTENSTRAUCH J, STOCK B. Who's Breaking the Rules? Studying Conformance to the HTTP Specifications and its Security Impact[C]// ASIA-CCS. Proceedings of the 19th ACM Asia Conference on Computer and Communications Security. New York: ACM, 2024: 843-855. |
| [5] | BOGNER J, KOTSTEIN S, PFAFF T. Do RESTful API Design Rules Have an Impact on the Understandability of Web APIs?[J]. Empirical Software Engineering, 2023, 28(6): 132-167. |
| [6] | OpenAPI Initiative. OpenAPI Specification[EB/OL]. (2021-02-15)[2024-10-14]. https://www.openapis.org. |
| [7] | GORSKI P L, MÖLLER S, WIEFLING S, et al. “I Just Looked for the Solution!” On Integrating Security-Relevant Information in Non-Security API Documentation to Support Secure Coding Practices[J]. IEEE Transactions on Software Engineering, 2021, 48(9): 3467-3484. |
| [8] | EHSAN A, ABUHALIQA M A M E, CATAL C, et al. RESTful API Testing Methodologies: Rationale, Challenges, and Solution Directions[J]. Applied Sciences, 2022, 12(9): 4369-4385. |
| [9] | GOLMOHAMMADI A, ZHANG Man, ARCURI A. Testing Restful APIs: A Survey[J]. ACM Transactions on Software Engineering and Methodology, 2023, 33(1): 1-41. |
| [10] | PATNAIK N, DWYER A, HALLETT J, et al. SLR: From Saltzer and Schroeder to 2021… 47 Years of Research on the Development and Validation of Security API Recommendations[J]. ACM Transactions on Software Engineering and Methodology, 2023, 32(3): 1-31. |
| [11] | ZHANG Man, ARCURI A. Open Problems in Fuzzing Restful APIs: A Comparison of Tools[J]. ACM Transactions on Software Engineering and Methodology, 2023, 32(6): 1-45. |
| [12] | ALONSO J C, MARTIN-LOPEZ A, SEGURA S, et al. ARTE: Automated Generation of Realistic Test Inputs for Web APIs[J]. IEEE Transactions on Software Engineering, 2022, 49(1): 348-363. |
| [13] | SWAGGER. API Development for Everyone[EB/OL]. [2024-10-14]. http://swagger.io/. |
| [14] | MANNING C D. Human Language Understanding & Reasoning[J]. Daedalus, 2022, 151(2): 127-138. |
| [15] | ZHAO Wayne Xin, ZHOU Kun, LI Junyi, et al. A Survey of Large Language Models[EB/OL]. (2023-12-24) [2024-10-14]. https://arxiv.org/abs/2303.18223. |
| [16] | LIU Yiheng, HAN Tianle, MA Siyuan, et al. Summary of Chatgpt-Related Research and Perspective towards the Future of Large Language Models[EB/OL]. (2023-08-18)[2024-10-14]. https://doi.org/10.1016/j.metrad.2023.100017. |
| [17] | OpenAI. ChatGPT[EB/OL]. [2024-10-14]. https://openai.com. |
| [18] | WEI J, WANG Xuezhi, SCHUURMANS D, et al. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models[J]. Advances in Neural Information Processing Systems, 2022, 35: 24824-24837. |
| [19] | BROWN T, MANN B, RYDER N, et al. Language Models Are Few-Shot Learners[J]. Advances in Neural Information Processing Systems, 2020, 33: 1877-1901. |
| [20] | OWASP. OWASP Cheat Sheet Series[EB/OL]. [2024-10-14]. https://cheatsheetseries.owasp.org. |
| [21] | KOTSTEIN S, BOGNER J. Which Restful API Design Rules are Important and How Do they Improve Software Quality? A Delphi Study with Industry Experts[C]// Springer. Service-Oriented Computing:15th Symposium and Summer School. Heidelberg: Springer, 2021: 154-173. |
| [22] | MASSE M. REST API Design Rulebook[M]. Sebastopol: O'Reilly Media, Inc., 2011. |
| [23] | PALMA F, GONZALEZ-HUERTA J, MOHA N, et al. Are Restful APIs Well-Designed? Detection of Their Linguistic (Anti) Patterns[C]// Springer. Service-Oriented Computing:13th International Conference. Heidelberg: Springer, 2015: 171-187. |
| [24] | PETRILLO F, MERLE P, MOHA N, et al. Are REST APIs for Cloud Computing Well-Designed? An Exploratory Study[C]// Springer. Service-Oriented Computing:14th International Conference. Heidelberg: Springer, 2016: 157-170. |
| [25] | PALMA F, OLSSON T, WINGKVIST A, et al. Assessing the Linguistic Quality of REST APIs for IoT Applications[J]. Journal of Systems and Software, 2022, 191: 111369. |
| [26] | SUBRAMANIAN H, RAJ P. Hands-On RESTful API Design Patterns and Best Practices: Design, Develop, and Deploy Highly Adaptable, Scalable, and Secure RESTful Web APIs[M]. Birmingham: Packt Publishing Ltd., 2019. |
| [27] | GREEN M, SMITH M. Developers are not the Enemy: The Need for Usable Security APIs[J]. IEEE Security & Privacy, 2016, 14(5): 40-46. |
| [28] | BRABRA H, MTIBAA A, PETRILLO F, et al. On Semantic Detection of Cloud API (Anti) Patterns[J]. Information and Software Technology, 2019, 107: 65-82. |
| [29] | NSFocus. REST API Security Design Guide[EB/OL]. (2020-06-22)[2024-10-14]. https://www.infoq.cn/article/eyj8icgmp3j3pm9uf4y4. |
| 绿盟科技. REST API安全设计指南[EB/OL]. (2020-06-22)[2024-10-14]. https://www.infoq.cn/article/eyj8icgmp3j3pm9uf4y4. | |
| [30] | OpenAI. OpenAPI Spec Validator[EB/OL]. (2023-10-13)[2024-10-14]. https://github.com/python-openapi/openapi-spec-validator/. |
| [31] | OpenAI. Completion-OpenAI API[EB/OL]. (2023-08-12)[2024-10-14]. https://beta.openai.com/docs/guides/completion/prompt-design. |
| [32] | KARAVISILEIOU A, MAINAS N, BOURAIMIS F, et al. Automated Ontology Instantiation of OpenAPI REST Service Descriptions[C]// SAI Conferences. Advances in Information and Communication:Proceedings of the 2021 Future of Information and Communication Conference (FICC). Heidelberg: Springer, 2021: 945-962. |
| [33] | GONCHAROV I. APIs.guru[EB/OL]. (2016-05-28)[2024-10-14]. https://apis.guru/. |
| [34] | FIELDING R, GETTYS J, MOGUL J, et al. Hypertext Transfer Protocol--HTTP/1.1[R]. Fremont: Internet Engineering Task Force (IETF), RFC 2616, 1999. |
| [1] | 陈平, 骆明宇. 云边端内核竞态漏洞大模型分析方法研究[J]. 信息网络安全, 2025, 25(7): 1007-1020. |
| [2] | 酆薇, 肖文名, 田征, 梁中军, 姜滨. 基于大语言模型的气象数据语义智能识别算法研究[J]. 信息网络安全, 2025, 25(7): 1163-1171. |
| [3] | 张学旺, 卢荟, 谢昊飞. 基于节点中心性和大模型的漏洞检测数据增强方法[J]. 信息网络安全, 2025, 25(4): 550-563. |
| [4] | 顾欢欢, 李千目, 刘臻, 王方圆, 姜宇. 基于虚假演示的隐藏后门提示攻击方法研究[J]. 信息网络安全, 2025, 25(4): 619-629. |
| [5] | 解梦飞, 傅建明, 姚人懿. 基于LLM的多媒体原生库模糊测试研究[J]. 信息网络安全, 2025, 25(3): 403-414. |
| [6] | 秦中元, 王田田, 刘伟强, 张群芳. 大语言模型水印技术研究进展[J]. 信息网络安全, 2025, 25(2): 177-193. |
| [7] | 焦诗琴, 张贵杨, 李国旗. 一种聚焦于提示的大语言模型隐私评估和混淆方法[J]. 信息网络安全, 2024, 24(9): 1396-1408. |
| [8] | 陈昊然, 刘宇, 陈平. 基于大语言模型的内生安全异构体生成方法[J]. 信息网络安全, 2024, 24(8): 1231-1240. |
| [9] | 项慧, 薛鋆豪, 郝玲昕. 基于语言特征集成学习的大语言模型生成文本检测[J]. 信息网络安全, 2024, 24(7): 1098-1109. |
| [10] | 郭祥鑫, 林璟锵, 贾世杰, 李光正. 针对大语言模型生成的密码应用代码安全性分析[J]. 信息网络安全, 2024, 24(6): 917-925. |
| [11] | 张长琳, 仝鑫, 佟晖, 杨莹. 面向网络安全领域的大语言模型技术综述[J]. 信息网络安全, 2024, 24(5): 778-793. |
| [12] | 秦振凯, 徐铭朝, 蒋萍. 基于提示学习的案件知识图谱构建方法及应用研究[J]. 信息网络安全, 2024, 24(11): 1773-1782. |
| [13] | 李娇, 张玉清, 吴亚飚. 面向网络安全关系抽取的大语言模型数据增强方法[J]. 信息网络安全, 2024, 24(10): 1477-1483. |
| [14] | 黄恺杰, 王剑, 陈炯峄. 一种基于大语言模型的SQL注入攻击检测方法[J]. 信息网络安全, 2023, 23(11): 84-93. |
| [15] | 刘超玲, 张棪, 杨慧然, 吴宏晶. 基于DPDK的虚拟化网络入侵防御系统设计与实现[J]. 信息网络安全, 2018, 18(5): 41-51. |
| 阅读次数 | ||||||
|
全文 |
|
|||||
|
摘要 |
|
|||||