Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Error in binary with tag DERP but no 'name' attribute #117

Merged
merged 6 commits into from
Oct 10, 2024
Merged

Conversation

aryan-rajoria
Copy link
Collaborator

Fixes AttributeError encountered when running blint on shared libraries.
fixes #116

 Parsing 1 binaries ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--[21:45:46] ERROR    Caught <class 'AttributeError'>: 'lief._lief.ELF.DynamicEntryRunPath' object has no attribute
                    'name' while parsing                                                                         
                    ~/Downloads/projects/blintdbpackages/wrapdb/build/openssl/subprojects/openssl-3
                    .0.8/libssl.so.                                                                              
                    Traceback (most recent call last):                                                           
                      File "~/projects/supplychain/blint/blint/binary.py", line 750, in parse      
                        metadata = add_elf_metadata(exe_file, metadata, parsed_obj)                              
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                              
                      File "~/projects/supplychain/blint/blint/binary.py", line 809, in            
                    add_elf_metadata                                                                             
                        metadata = add_elf_dynamic_entries(dynamic_entries, metadata)                            
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                            
                      File "~/projects/supplychain/blint/blint/binary.py", line 920, in            
                    add_elf_dynamic_entries                                                                      
                        "name": demangle_symbolic_name(entry.name),                                              
                                                       ^^^^^^^^^^                                                
                    AttributeError: 'lief._lief.ELF.DynamicEntryRunPath' object has no attribute 'name' 

Signed-off-by: Aryan Rajoria <aryanrajoria1003@gmail.com>
Signed-off-by: Aryan Rajoria <aryanrajoria1003@gmail.com>
@aryan-rajoria
Copy link
Collaborator Author

fixed.json
previous.json

blint/binary.py Outdated Show resolved Hide resolved
Signed-off-by: Aryan Rajoria <aryanrajoria1003@gmail.com>
blint/binary.py Outdated
elif hasattr(entry, 'runpath'):
metadata["dynamic_entries"].append(
{
"runpath": demangle_symbolic_name(entry.runpath),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got me thinking. Perhaps the name is "runpath" and the value is the demangled value.

Copy link
Collaborator Author

@aryan-rajoria aryan-rajoria Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When debugging an entry I get name: libfdk_acc.so, and value: 318 when tag is NEEDED.
and, in case of RUNPATH I get:
name: '$ORIGIN/'
value: 375

please suggest if this is okay?

@prabhu
Copy link
Member

prabhu commented Oct 8, 2024

@aryan-rajoria the attached files do not have those tags. Can you run the default command and share the metadata file instead?

@aryan-rajoria
Copy link
Collaborator Author

aryan-rajoria commented Oct 10, 2024

aac-enc-metadata.json

Metadata generated with the changes

Signed-off-by: Aryan Rajoria <aryanrajoria1003@gmail.com>
Signed-off-by: Aryan Rajoria <aryanrajoria1003@gmail.com>
@aryan-rajoria
Copy link
Collaborator Author

I have added RUNPATH and RPATH seperately,
aac_enc metadata above uses the RUNPATH, while I could not find examples of binaries using RPATH as gcc has deprecated it. I compiled a small script using --disable-new-dtags arguments in gcc. Here is the results.
rpath-example-metadata.json

Copy link
Member

@prabhu prabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@prabhu prabhu merged commit 9ee86bd into main Oct 10, 2024
20 checks passed
@prabhu prabhu deleted the fix-116 branch October 10, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'lief._lief.ELF.DynamicEntryRunPath' object has no attribute 'name'
2 participants