Segmentation fault trying to deploy CloudFormation template using AWS CLI
Segmentation fault (core dumped)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics | Code.
🔒 Related Stories: Bugs | AWS Security | Secure Code
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hmmm…
./deploy/root-orgadminrole/organizations_account_project.sh: line 67: 1398 Segmentation fault (core dumped)
What is causing this, I wonder? And where was the core dumpted?
Let’s take a look at line 67.
It’s trying to open a file:

Let’s try to open the file. I don’t see the problem. It looks like the other files I’ve deployed with similar code.

Well, I got a segmentation fault before and wrote about it here:
This was the end result of that post:
So I’m wondering if it has to do with sourcing the same file from two different directories in the same script — but I’m not sure.
Well, I’m sourcing the same files from within multiple scripts in a bunch of places and hasn’t caused a problem till now. Hmm.
Well, I comment out the the sourced file that I suspect is the problem from the last script.

That confirms that something in a sourced file is causing the segmentation fault.
Let’s head over to that file.
I’m sourcing some things at the top of the file, some of which are redundant. Hmm. But let’s start by commenting out the last two:

Like this:

When I comment out those files I don’t get the error anymore even when I include the above file that was previously causing a problem.
I verify that both those files exist. Then I take a look at those files.
My route table file also references the shared functions:

Here’s something interesting. The security group file tries to include the VPC file:

So then the VPC file will try to include the security group file.
And there we have a circular dependency.
Let’s remove the VPC file from the security group sourced files and see what happens.

I restore the sourced files in the vpc_functions.sh file:

And no segmentation fault.
So what can I do if I need to reference a function in the VPC file when deploying security groups? I can move those particular functions to a shared network_functions file to alleviate the circular dependency.
I wish the error message was more specific as to what the problem was in this case but figured it out with a little investigation.
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2023
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight LabNeed Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for PresentationFollow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
