# Dependency Confusion
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** π¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
{% embed url="https://websec.nl/" %}
## Basic Information
μμ½νμλ©΄, μμ‘΄μ± νΌλ μ·¨μ½μ μ νλ‘μ νΈκ° **μλͺ» μ² μλ** μ΄λ¦, **μ‘΄μ¬νμ§ μλ** μ΄λ¦ λλ **μ§μ λμ§ μμ λ²μ **μ λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©ν λ λ°μνλ©°, μ¬μ©λ μμ‘΄μ± μ μ₯μκ° **곡κ°** μ μ₯μμμ **μ
λ°μ΄νΈλ λ²μ μ μμ§**ν μ μλλ‘ νμ©ν©λλ€.
* **μλͺ» μ² μλ**: **`reqests`**λ₯Ό λμ νμ¬ `requests`λ₯Ό κ°μ Έμ€κΈ°
* **μ‘΄μ¬νμ§ μλ**: λ μ΄μ **μ‘΄μ¬νμ§ μλ** λ΄λΆ λΌμ΄λΈλ¬λ¦¬μΈ `company-logging` κ°μ Έμ€κΈ°
* **μ§μ λμ§ μμ λ²μ **: **λ΄λΆ**μ **μ‘΄μ¬νλ** `company-requests` λΌμ΄λΈλ¬λ¦¬λ₯Ό κ°μ Έμ€μ§λ§, μ μ₯μκ° **λ ν° λ²μ **μ΄ μλμ§ νμΈνκΈ° μν΄ **κ³΅κ° μ μ₯μ**λ₯Ό νμΈν©λλ€.
## Exploitation
{% hint style="warning" %}
λͺ¨λ κ²½μ°μ 곡격μλ νΌν΄ νμ¬μμ μ¬μ©νλ λΌμ΄λΈλ¬λ¦¬μ **μ΄λ¦μ κ°μ§ μ
μ± ν¨ν€μ§**λ₯Ό κ²μνκΈ°λ§ νλ©΄ λ©λλ€.
{% endhint %}
### Misspelled & Inexistent
νμ¬κ° **λ΄λΆ λΌμ΄λΈλ¬λ¦¬κ° μλ λΌμ΄λΈλ¬λ¦¬**λ₯Ό κ°μ Έμ€λ €κ³ νλ€λ©΄, λΌμ΄λΈλ¬λ¦¬ μ μ₯μκ° **κ³΅κ° μ μ₯μ**μμ μ΄λ₯Ό κ²μν κ°λ₯μ±μ΄ λμ΅λλ€. 곡격μκ° μ΄λ₯Ό μμ±νλ€λ©΄, κ·νμ μ½λμ μ€ν μ€μΈ λ¨Έμ μ λ§€μ° λμ νλ₯ λ‘ μμλ κ²μ
λλ€.
### Unspecified Version
κ°λ°μκ° μ¬μ©λ λΌμ΄λΈλ¬λ¦¬μ **λ²μ μ μ§μ νμ§ μκ±°λ** λ¨μ§ **μ£Όμ λ²μ **λ§ μ§μ νλ κ²½μ°κ° λ§€μ° νν©λλ€. κ·Έλ¬λ©΄ μΈν°ν리ν°λ ν΄λΉ μꡬ μ¬νμ λ§λ **μ΅μ λ²μ **μ λ€μ΄λ‘λνλ €κ³ μλν©λλ€.\
λΌμ΄λΈλ¬λ¦¬κ° **μ μλ €μ§ μΈλΆ λΌμ΄λΈλ¬λ¦¬**(μ: python `requests`)μΈ κ²½μ°, **곡격μλ λ§μ κ²μ ν μ μμ΅λλ€**, μλνλ©΄ κ·Έλ `requests`λΌλ μ΄λ¦μ λΌμ΄λΈλ¬λ¦¬λ₯Ό λ§λ€ μ μκΈ° λλ¬Έμ
λλ€(κ·Έκ° μλ μ μκ° μλ ν).\
κ·Έλ¬λ λΌμ΄λΈλ¬λ¦¬κ° **λ΄λΆ**μΈ κ²½μ°, μ΄ μμμ `requests-company`μ κ°μ΄, **λΌμ΄λΈλ¬λ¦¬ μ μ₯μ**κ° **μΈλΆμμλ μλ‘μ΄ λ²μ μ νμΈ**ν μ μλλ‘ νμ©νλ©΄, 곡κ°μ μΌλ‘ μ¬μ© κ°λ₯ν λ μ΅μ λ²μ μ κ²μν©λλ€.\
λ°λΌμ **곡격μκ°** νμ¬κ° `requests-company` λΌμ΄λΈλ¬λ¦¬ **λ²μ 1.0.1**(μκ·λͺ¨ μ
λ°μ΄νΈ νμ©)μ μ¬μ©νκ³ μλ€λ κ²μ μκ³ μλ€λ©΄, κ·Έλ `requests-company` **λ²μ 1.0.2**λ₯Ό **κ²μ**ν μ μμΌλ©°, νμ¬λ λ΄λΆ λΌμ΄λΈλ¬λ¦¬ λμ ν΄λΉ λΌμ΄λΈλ¬λ¦¬λ₯Ό **μ¬μ©νκ² λ©λλ€**.
## AWS Fix
μ΄ μ·¨μ½μ μ AWS **CodeArtifact**μμ λ°κ²¬λμμ΅λλ€(μμΈν λ΄μ©μ [**μ΄ λΈλ‘κ·Έ κ²μλ¬Ό**](https://zego.engineering/dependency-confusion-in-aws-codeartifact-86b9ff68963d)μμ νμΈνμΈμ).\
AWSλ λΌμ΄λΈλ¬λ¦¬κ° λ΄λΆμΈμ§ μΈλΆμΈμ§ μ§μ ν μ μλλ‘ νμ¬ μΈλΆ μ μ₯μμμ λ΄λΆ μμ‘΄μ±μ λ€μ΄λ‘λνλ κ²μ λ°©μ§νμ΅λλ€.
## Finding Vulnerable Libraries
[**μμ‘΄μ± νΌλμ λν μλ κ²μλ¬Ό**](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610)μμ μ μλ μλ°μ€ν¬λ¦½νΈ νλ‘μ νΈμ μμ‘΄μ±μ ν¬ν¨νλ μμ² κ°μ λ
ΈμΆλ package.json νμΌμ κ²μνμ΅λλ€.
## References
* [https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610)
* [https://zego.engineering/dependency-confusion-in-aws-codeartifact-86b9ff68963d](https://zego.engineering/dependency-confusion-in-aws-codeartifact-86b9ff68963d)
{% embed url="https://websec.nl/" %}
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** π¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}